setLabel Names

This commit is contained in:
Niko Jochim 2020-06-18 12:55:37 +02:00
parent f363d30f15
commit 8df133f896
3 changed files with 11 additions and 5 deletions

View File

@ -35,8 +35,10 @@ class HUD: GKEntity {
init(size: CGSize) { init(size: CGSize) {
hostLabel = SKLabelNode(text: GameCenterManager.sharedInstance.hostingPlayer?.displayName) hostLabel = SKLabelNode(text: GameCenterManager.sharedInstance.hostingPlayer?.displayName)
hostLabel.name = "hostLabel"
hostUnitsLabel = SKLabelNode(text: "500" ) hostUnitsLabel = SKLabelNode(text: "500" )
peerLabel = SKLabelNode(text: GameCenterManager.sharedInstance.peerPlayer?.displayName) peerLabel = SKLabelNode(text: GameCenterManager.sharedInstance.peerPlayer?.displayName)
peerLabel.name = "peerLabel"
peerUnitsLabel = SKLabelNode(text: "500") peerUnitsLabel = SKLabelNode(text: "500")
roundTimerLabel = SKLabelNode(text: "") roundTimerLabel = SKLabelNode(text: "")

View File

@ -47,7 +47,7 @@ class RoundTimer: Timer {
@objc func onTimerFires() @objc func onTimerFires()
{ {
timeLeft -= 1
EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded)) EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded))
if timeLeft == 0 { if timeLeft == 0 {
@ -56,6 +56,7 @@ class RoundTimer: Timer {
if !MultiplayerNetwork.sharedInstance.isSending { if !MultiplayerNetwork.sharedInstance.isSending {
MultiplayerNetwork.sharedInstance.sendPlayerMoves(localRoundData: DataService.sharedInstance.localRoundData) MultiplayerNetwork.sharedInstance.sendPlayerMoves(localRoundData: DataService.sharedInstance.localRoundData)
} }
calculate = true
if timeLeft <= 0 { if timeLeft <= 0 {
if calculate if calculate
&& !RoundCalculatorService.sharedInstance.isCalculating && !RoundCalculatorService.sharedInstance.isCalculating

View File

@ -29,10 +29,11 @@ class GameScene: SKScene{
} }
return return
} }
override func didMove(to view: SKView) { 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(pauseGame), name: Notification.Name("pauseGame"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(resumeGame), name: Notification.Name("resumeGame"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(resumeGame), name: Notification.Name("resumeGame"), object: nil)
} }
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else { guard let touch = touches.first else {
@ -78,6 +79,7 @@ class GameScene: SKScene{
override func update(_ currentTime: TimeInterval) { override func update(_ currentTime: TimeInterval) {
if entityManager.entities.count != 0 { if entityManager.entities.count != 0 {
entityManager.getBackground()?.update(deltaTime: currentTime) entityManager.getBackground()?.update(deltaTime: currentTime)
print("Update")
if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects { if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects {
gameEnd() gameEnd()
} }
@ -127,6 +129,7 @@ class GameScene: SKScene{
} }
func gameEnd(){ func gameEnd(){
print("Game END")
gameEndEffects = true gameEndEffects = true
let winnerNode:String? let winnerNode:String?
GameCenterManager.sharedInstance.gameEnded = false GameCenterManager.sharedInstance.gameEnded = false