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