From b29111cb9e55c6cd214e5a7d2c8a21a78357c36a Mon Sep 17 00:00:00 2001 From: Niko Jochim <82joni1bif@hft-stuttgart.de> Date: Sun, 7 Jun 2020 12:00:12 +0200 Subject: [PATCH] create gameEnd Trigger --- GoldWars/GoldWars/GameCenterManager.swift | 8 ++++++-- GoldWars/GoldWars/RoundCalculatorService.swift | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) 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