Skip to content

Commit

Permalink
Add tower card
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa Mae committed Mar 23, 2024
1 parent 135e29e commit b4a07a3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "arrowTower.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class HomeComponent: TFComponent {
var lifeLeft: Int {
didSet {
// Update the life left in the LabelComponent when it changes
guard let labelComponent = entity?.component(ofType: LabelComponent.self), labelComponent.name == "life" else {
guard let labelComponent = entity?.component(ofType: LabelComponent.self),
labelComponent.name == "life" else {
return
}
labelComponent.changeText(String(lifeLeft))
Expand All @@ -21,7 +22,8 @@ class HomeComponent: TFComponent {
var points = 0 {
didSet {
// Update the points in the LabelComponent when it changes
guard let labelComponent = entity?.component(ofType: LabelComponent.self), labelComponent.name == "point" else {
guard let labelComponent = entity?.component(ofType: LabelComponent.self),
labelComponent.name == "point" else {
return
}
labelComponent.changeText(String(points))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class BaseTower: TFEntity {
player: Player) {
super.init()

createHealthComponent(maxHealth: maxHealth)
createSpriteComponent(textureNames: textureNames, size: size, key: key, position: position)
createHealthComponent(maxHealth: maxHealth)
createPositionComponent(position: position)
createPlayerComponent(player: player)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@
import Foundation

struct SpawnableEntities {
static let playerSpawnableEntities: [(TFEntity & PlayerSpawnable).Type] = [MeleeUnit.self, SoldierUnit.self]
static let playerSpawnableEntities: [(TFEntity & PlayerSpawnable).Type] =
[
MeleeUnit.self,
SoldierUnit.self,
ArrowTower.self
]
}

0 comments on commit b4a07a3

Please sign in to comment.