diff --git a/GoldWars/GoldWars/GameCenterManager.swift b/GoldWars/GoldWars/GameCenterManager.swift index f6b1976..9a81295 100644 --- a/GoldWars/GoldWars/GameCenterManager.swift +++ b/GoldWars/GoldWars/GameCenterManager.swift @@ -44,6 +44,8 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG var entityManager = EntityManager.gameEMInstance var localPlayerRandomNumber: RandomNumber? var initIsFinish = false + var gameEnded = false + var winner:String? var gameScene: GameScene? static var isAuthenticated: Bool { return GKLocalPlayer.local.isAuthenticated @@ -225,10 +227,12 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG os_log("Spiel startet", log: LOG, type: .info) case 4: os_log("State 4 erhalten, Peer hat verloren", log: LOG, type: .info) - // TODO: Trigger Loser Scene + winner = hostingPlayer?.displayName + gameEnded = true case 5: os_log("State 5 erhalten, Peer hat gewonnen", log: LOG, type: .info) - // TODO: Trigger Winner Scene + winner = peerPlayer?.displayName + gameEnded = true default: break } diff --git a/GoldWars/GoldWars/RoundCalculatorService.swift b/GoldWars/GoldWars/RoundCalculatorService.swift index 95f0c72..c1d1904 100644 --- a/GoldWars/GoldWars/RoundCalculatorService.swift +++ b/GoldWars/GoldWars/RoundCalculatorService.swift @@ -158,7 +158,8 @@ class RoundCalculatorService { winner = determineWinner(by: "capture") } winner == GameCenterManager.sharedInstance.hostingPlayer?.displayName ? GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 4)) : GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 5)) - //TODO: Trigger Winner/Loser-Scene for Server + GameCenterManager.sharedInstance.winner = winner + GameCenterManager.sharedInstance.gameEnded = true return } currentRound += 1