From 985e4f48cbcf49451549bd9f289f2b88ce0106ac Mon Sep 17 00:00:00 2001 From: Niko Jochim <82joni1bif@hft-stuttgart.de> Date: Thu, 2 Jul 2020 12:53:45 +0200 Subject: [PATCH] FIX trigger GameQuit --- GoldWars/GoldWars/Entities/HUD.swift | 6 +++++- GoldWars/GoldWars/Entities/Modal.swift | 1 + GoldWars/GoldWars/GameCenterManager.swift | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/GoldWars/GoldWars/Entities/HUD.swift b/GoldWars/GoldWars/Entities/HUD.swift index a66fdc6..1a40c51 100644 --- a/GoldWars/GoldWars/Entities/HUD.swift +++ b/GoldWars/GoldWars/Entities/HUD.swift @@ -61,7 +61,11 @@ class HUD: GKEntity { y: EntityManager.gameEMInstance.scene.size.height * 0.1), onButtonPress: { } ) - leaveGame = ButtonNode(textureName: "exitButton", text: "" , isEnabled: true, position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.05, y: EntityManager.gameEMInstance.scene.size.height * 0.11), onButtonPress: { + leaveGame = ButtonNode(textureName: "exitButton", + text: "" , + isEnabled: true, + position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.05, y: EntityManager.gameEMInstance.scene.size.height * 0.11), + onButtonPress: { EntityManager.gameEMInstance.add(Modal(modaltype: .QuitGame, base: nil, anchorPoint: CGPoint(x: EntityManager.gameEMInstance.scene.size.width / 2 , y: EntityManager.gameEMInstance.scene.size.height / 2), gameScene: EntityManager.gameEMInstance.scene, currentDraggedBase: nil, touchLocation: nil, collisionBase: nil)) }) leaveGame.size = CGSize(width: 120, height: 120); diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index 0407dba..fc8dde7 100644 --- a/GoldWars/GoldWars/Entities/Modal.swift +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -105,6 +105,7 @@ class Modal: GKEntity{ GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 6)) GameCenterManager.sharedInstance.opponentQuit = false GameCenterManager.sharedInstance.quitGame = true + (EntityManager.gameEMInstance.scene as! GameScene).gameQuit() })) case .PauseGame: break diff --git a/GoldWars/GoldWars/GameCenterManager.swift b/GoldWars/GoldWars/GameCenterManager.swift index 7f07d5c..ead0e7d 100644 --- a/GoldWars/GoldWars/GameCenterManager.swift +++ b/GoldWars/GoldWars/GameCenterManager.swift @@ -178,6 +178,7 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG (EntityManager.gameEMInstance.scene as! GameScene).gameEnd() case 6: os_log("State 6 erhalten, Peer hat Spiel verlassen ", log: LOG, type: .info) + (EntityManager.gameEMInstance.scene as! GameScene).gameQuit() opponentQuit = true quitGame = true default: