From 5d8df463610f8887fd8d006051717166f9b944e8 Mon Sep 17 00:00:00 2001 From: Niko Jochim <82joni1bif@hft-stuttgart.de> Date: Thu, 2 Jul 2020 12:34:29 +0200 Subject: [PATCH] change trigger GameEnd --- GoldWars/GoldWars/GameCenterManager.swift | 2 ++ GoldWars/GoldWars/RoundCalculatorService.swift | 4 ++-- GoldWars/GoldWars/Scenes/GameScene.swift | 7 +------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/GoldWars/GoldWars/GameCenterManager.swift b/GoldWars/GoldWars/GameCenterManager.swift index fbf0c8d..7f07d5c 100644 --- a/GoldWars/GoldWars/GameCenterManager.swift +++ b/GoldWars/GoldWars/GameCenterManager.swift @@ -170,10 +170,12 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG os_log("State 4 erhalten, Peer hat verloren", log: LOG, type: .info) winner = hostingPlayer?.displayName gameEnded = true + (EntityManager.gameEMInstance.scene as! GameScene).gameEnd() case 5: os_log("State 5 erhalten, Peer hat gewonnen", log: LOG, type: .info) winner = peerPlayer?.displayName gameEnded = true + (EntityManager.gameEMInstance.scene as! GameScene).gameEnd() case 6: os_log("State 6 erhalten, Peer hat Spiel verlassen ", log: LOG, type: .info) opponentQuit = true diff --git a/GoldWars/GoldWars/RoundCalculatorService.swift b/GoldWars/GoldWars/RoundCalculatorService.swift index 4aacba7..d146659 100644 --- a/GoldWars/GoldWars/RoundCalculatorService.swift +++ b/GoldWars/GoldWars/RoundCalculatorService.swift @@ -20,7 +20,7 @@ class RoundCalculatorService { let ATK_BOOST_MULTIPLICATOR = 1.1 let DEF_BOOST_MULTIPLICATOR = 1.1 - let MAX_ROUNDS = 20 + let MAX_ROUNDS = 3 var currentRound = 1 var isCalculating = false var numberOfAttacks = 0 @@ -160,7 +160,7 @@ class RoundCalculatorService { winner == GameCenterManager.sharedInstance.hostingPlayer?.displayName ? GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 4)) : GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 5)) GameCenterManager.sharedInstance.winner = winner GameCenterManager.sharedInstance.gameEnded = true - + (EntityManager.gameEMInstance.scene as! GameScene).gameEnd() // Update EloSystem if winner == GameCenterManager.sharedInstance.hostingPlayer?.displayName { EloHelper.updateEloScore(winner: GameCenterManager.sharedInstance.hostingPlayer!, hatDenNikoGemacht: GameCenterManager.sharedInstance.peerPlayer!) diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index 93d4548..762e25e 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -78,12 +78,7 @@ class GameScene: SKScene{ override func update(_ currentTime: TimeInterval) { entityManager.getBackground()?.update(deltaTime: currentTime) - if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects { - gameEnd() - } - if GameCenterManager.sharedInstance.quitGame { - gameQuit() - } + }