Skip to content

Commit

Permalink
Merge pull request #29 from Vanessamae23/main
Browse files Browse the repository at this point in the history
Add tower card
  • Loading branch information
zheng-ze authored Mar 23, 2024
2 parents 135e29e + b4a07a3 commit 5a21737
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 5a21737

Please sign in to comment.