Use player move type to update unit count label

This commit is contained in:
Marcel Schwarz 2020-06-23 20:52:27 +02:00
parent 0b2b552d16
commit d05364708b
3 changed files with 6 additions and 3 deletions

View File

@ -49,9 +49,11 @@ class Base: GKEntity{
self.unitCount -= units
base.unitCount += units
self.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(self.unitCount)"
if base.ownershipPlayer == GKLocalPlayer.local {
if playerMoveType == .TxnMove {
base.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(base.unitCount)"
}
base.ownershipPlayer = self.ownershipPlayer
DataService.sharedInstance.addMove(playerMove: PlayerMove(fromBase: self.baseID,
toBase: base.baseID,

View File

@ -109,10 +109,11 @@ class Modal: GKEntity{
}
func sendUnits(currentDraggedBase: Base?, touchLocation: CGPoint, gameScene: GameScene, collisionBase: Base?){
let moveType: PlayerMoveType = self.type == ModalType.BaseAttack ? .AtkMove : .TxnMove
for base in currentDraggedBase!.adjacencyList {
if base == collisionBase {
RoundCalculatorService.sharedInstance.increaseMoveCounter(ownBase: currentDraggedBase?.ownershipPlayer == base.ownershipPlayer)
entityManager.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: PlayerMoveType.AtkMove, units: Int(GameScene.sendUnits)))!)
entityManager.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: moveType, units: Int(GameScene.sendUnits)))!)
GameScene.sendUnits = 0
}
}

View File

@ -264,7 +264,7 @@ class GameScene: SKScene{
}
func isAttackMove() -> Bool {
return collisionBase?.ownershipPlayer != currentDraggedBase?.ownershipPlayer
return collisionBase?.ownershipPlayer != currentDraggedBase?.ownershipPlayer && !(collisionBase?.changeOwnership ?? false)
}
@objc func pauseGame() -> Void {