create gameEnd Trigger

This commit is contained in:
Niko Jochim 2020-06-07 12:00:12 +02:00
parent dc3ef818df
commit b29111cb9e
2 changed files with 8 additions and 3 deletions

View File

@ -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
}

View File

@ -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