change trigger GameEnd

This commit is contained in:
Niko Jochim 2020-07-02 12:34:29 +02:00
parent c7d9d63752
commit 5d8df46361
3 changed files with 5 additions and 8 deletions

View File

@ -170,10 +170,12 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
os_log("State 4 erhalten, Peer hat verloren", log: LOG, type: .info) os_log("State 4 erhalten, Peer hat verloren", log: LOG, type: .info)
winner = hostingPlayer?.displayName winner = hostingPlayer?.displayName
gameEnded = true gameEnded = true
(EntityManager.gameEMInstance.scene as! GameScene).gameEnd()
case 5: case 5:
os_log("State 5 erhalten, Peer hat gewonnen", log: LOG, type: .info) os_log("State 5 erhalten, Peer hat gewonnen", log: LOG, type: .info)
winner = peerPlayer?.displayName winner = peerPlayer?.displayName
gameEnded = true gameEnded = true
(EntityManager.gameEMInstance.scene as! GameScene).gameEnd()
case 6: case 6:
os_log("State 6 erhalten, Peer hat Spiel verlassen ", log: LOG, type: .info) os_log("State 6 erhalten, Peer hat Spiel verlassen ", log: LOG, type: .info)
opponentQuit = true opponentQuit = true

View File

@ -20,7 +20,7 @@ class RoundCalculatorService {
let ATK_BOOST_MULTIPLICATOR = 1.1 let ATK_BOOST_MULTIPLICATOR = 1.1
let DEF_BOOST_MULTIPLICATOR = 1.1 let DEF_BOOST_MULTIPLICATOR = 1.1
let MAX_ROUNDS = 20 let MAX_ROUNDS = 3
var currentRound = 1 var currentRound = 1
var isCalculating = false var isCalculating = false
var numberOfAttacks = 0 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)) 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.winner = winner
GameCenterManager.sharedInstance.gameEnded = true GameCenterManager.sharedInstance.gameEnded = true
(EntityManager.gameEMInstance.scene as! GameScene).gameEnd()
// Update EloSystem // Update EloSystem
if winner == GameCenterManager.sharedInstance.hostingPlayer?.displayName { if winner == GameCenterManager.sharedInstance.hostingPlayer?.displayName {
EloHelper.updateEloScore(winner: GameCenterManager.sharedInstance.hostingPlayer!, hatDenNikoGemacht: GameCenterManager.sharedInstance.peerPlayer!) EloHelper.updateEloScore(winner: GameCenterManager.sharedInstance.hostingPlayer!, hatDenNikoGemacht: GameCenterManager.sharedInstance.peerPlayer!)

View File

@ -78,12 +78,7 @@ class GameScene: SKScene{
override func update(_ currentTime: TimeInterval) { override func update(_ currentTime: TimeInterval) {
entityManager.getBackground()?.update(deltaTime: currentTime) entityManager.getBackground()?.update(deltaTime: currentTime)
if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects {
gameEnd()
}
if GameCenterManager.sharedInstance.quitGame {
gameQuit()
}
} }