From 8df133f8968b7cd10dda7bfd173783f69beaf8aa Mon Sep 17 00:00:00 2001 From: Niko Jochim <82joni1bif@hft-stuttgart.de> Date: Thu, 18 Jun 2020 12:55:37 +0200 Subject: [PATCH] setLabel Names --- GoldWars/GoldWars/Entities/HUD.swift | 2 ++ GoldWars/GoldWars/RoundTimer.swift | 3 ++- GoldWars/GoldWars/Scenes/GameScene.swift | 11 +++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/GoldWars/GoldWars/Entities/HUD.swift b/GoldWars/GoldWars/Entities/HUD.swift index 53ced57..5079e73 100644 --- a/GoldWars/GoldWars/Entities/HUD.swift +++ b/GoldWars/GoldWars/Entities/HUD.swift @@ -35,8 +35,10 @@ class HUD: GKEntity { init(size: CGSize) { hostLabel = SKLabelNode(text: GameCenterManager.sharedInstance.hostingPlayer?.displayName) + hostLabel.name = "hostLabel" hostUnitsLabel = SKLabelNode(text: "500" ) peerLabel = SKLabelNode(text: GameCenterManager.sharedInstance.peerPlayer?.displayName) + peerLabel.name = "peerLabel" peerUnitsLabel = SKLabelNode(text: "500") roundTimerLabel = SKLabelNode(text: "") diff --git a/GoldWars/GoldWars/RoundTimer.swift b/GoldWars/GoldWars/RoundTimer.swift index f7913bf..af64e15 100644 --- a/GoldWars/GoldWars/RoundTimer.swift +++ b/GoldWars/GoldWars/RoundTimer.swift @@ -47,7 +47,7 @@ class RoundTimer: Timer { @objc func onTimerFires() { - + timeLeft -= 1 EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded)) if timeLeft == 0 { @@ -56,6 +56,7 @@ class RoundTimer: Timer { if !MultiplayerNetwork.sharedInstance.isSending { MultiplayerNetwork.sharedInstance.sendPlayerMoves(localRoundData: DataService.sharedInstance.localRoundData) } + calculate = true if timeLeft <= 0 { if calculate && !RoundCalculatorService.sharedInstance.isCalculating diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index 393e59b..09da3f9 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -29,10 +29,11 @@ class GameScene: SKScene{ } return } - override func didMove(to view: SKView) { - NotificationCenter.default.addObserver(self, selector: #selector(pauseGame), name: Notification.Name("pauseGame"), object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(resumeGame), name: Notification.Name("resumeGame"), object: nil) - } + + override func didMove(to view: SKView) { + NotificationCenter.default.addObserver(self, selector: #selector(pauseGame), name: Notification.Name("pauseGame"), object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(resumeGame), name: Notification.Name("resumeGame"), object: nil) +} override func touchesEnded(_ touches: Set, with event: UIEvent?) { guard let touch = touches.first else { @@ -78,6 +79,7 @@ class GameScene: SKScene{ override func update(_ currentTime: TimeInterval) { if entityManager.entities.count != 0 { entityManager.getBackground()?.update(deltaTime: currentTime) + print("Update") if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects { gameEnd() } @@ -127,6 +129,7 @@ class GameScene: SKScene{ } func gameEnd(){ + print("Game END") gameEndEffects = true let winnerNode:String? GameCenterManager.sharedInstance.gameEnded = false