refactor variables
This commit is contained in:
parent
9c751cc84f
commit
bd5d142a43
@ -14,14 +14,14 @@ class Base: GKEntity {
|
|||||||
|
|
||||||
var unitCount: Int
|
var unitCount: Int
|
||||||
var adjacencyList: Array<Base>
|
var adjacencyList: Array<Base>
|
||||||
var changeOwnerShip: Bool
|
var changeOwnership: Bool
|
||||||
var ownerShipPlayer: GKPlayer?
|
var ownershipPlayer: GKPlayer?
|
||||||
|
|
||||||
init(position: CGPoint, player: GKPlayer? = nil, team: Team? = nil) {
|
init(position: CGPoint, player: GKPlayer? = nil, team: Team? = nil) {
|
||||||
self.unitCount = 0
|
self.unitCount = 0
|
||||||
self.adjacencyList = [Base]()
|
self.adjacencyList = [Base]()
|
||||||
self.changeOwnerShip = false
|
self.changeOwnership = false
|
||||||
self.ownerShipPlayer = player
|
self.ownershipPlayer = player
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))
|
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))
|
||||||
@ -32,8 +32,8 @@ class Base: GKEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func attackBase(base: Base, units:Int) -> [GKEntity]{
|
func attackBase(base: Base, units:Int) -> [GKEntity]{
|
||||||
base.changeOwnerShip = true
|
base.changeOwnership = true
|
||||||
base.ownerShipPlayer = self.ownerShipPlayer
|
base.ownershipPlayer = self.ownershipPlayer
|
||||||
self.unitCount -= units
|
self.unitCount -= units
|
||||||
base.unitCount += units
|
base.unitCount += units
|
||||||
return [self, base]
|
return [self, base]
|
||||||
|
@ -92,13 +92,13 @@ class EntityManager {
|
|||||||
self.entities.update(with: entity)
|
self.entities.update(with: entity)
|
||||||
let base = (entity as! Base)
|
let base = (entity as! Base)
|
||||||
|
|
||||||
if base.changeOwnerShip {
|
if base.changeOwnership {
|
||||||
base.addComponent(
|
base.addComponent(
|
||||||
TeamComponent(
|
TeamComponent(
|
||||||
team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team,
|
team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team,
|
||||||
position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!,
|
position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!,
|
||||||
player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player))
|
player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player))
|
||||||
base.changeOwnerShip = false
|
base.changeOwnership = false
|
||||||
scene.addChild(base.component(ofType: TeamComponent.self)!.fire)
|
scene.addChild(base.component(ofType: TeamComponent.self)!.fire)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user