diff --git a/GoldWars/GoldWars/GameCenterManager.swift b/GoldWars/GoldWars/GameCenterManager.swift index 90712b9..09833ab 100644 --- a/GoldWars/GoldWars/GameCenterManager.swift +++ b/GoldWars/GoldWars/GameCenterManager.swift @@ -110,7 +110,6 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG } func match(_ match: GKMatch, didReceive data: Data, fromRemotePlayer player: GKPlayer) { - print("I am here") if myMatch != match { return } let jsonDecoder = JSONDecoder() if let randomNumberFromPeer = try? jsonDecoder.decode(RandomNumber.self, from: data) { @@ -171,14 +170,12 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG DataService.sharedInstance.addRemotePlayerMoves(playerName: player.displayName, localRoundData: roundData) } if let snapshotModel = try? jsonDecoder.decode(SnapshotModel.self, from: data) { - print("entered syncing state in match") StateManager.sharedInstance.changeState(wantedState: .syncingSt) DataService.sharedInstance.snapshotModel = snapshotModel RoundCalculatorService.sharedInstance.currentRound += 1 entityManager.getHUD()?.setCurrentRound(round: RoundCalculatorService.sharedInstance.currentRound) entityManager.updateSnapshotModel(snapshotModel: snapshotModel) entityManager.getHUD()?.startWithDuration() - print("entered gameSt in match snapshot") StateManager.sharedInstance.changeState(wantedState: .gameSt) } if let mapModel = try? jsonDecoder.decode(MapGenerationModel.self, from: data) { @@ -192,8 +189,8 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG StateManager.sharedInstance.gameSc = scene sendStateToPeers(state: State(state: 2)) os_log("State 2 wurde an Host gesendet", log: LOG, type: .info) - // initIsFinish = true - // os_log("Peer startet Spiel", log: LOG, type: .info) + // initIsFinish = true + // os_log("Peer startet Spiel", log: LOG, type: .info) } MultiplayerNetwork.sharedInstance.isSending = false } @@ -252,7 +249,6 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG } func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) { - print("entered syncing state in didfindmatch") StateManager.sharedInstance.changeState(wantedState: .syncingSt) viewController.dismiss(animated: true, completion: nil) myMatch = match diff --git a/GoldWars/GoldWars/RoundCalculatorService.swift b/GoldWars/GoldWars/RoundCalculatorService.swift index c7707b2..adcb5d5 100644 --- a/GoldWars/GoldWars/RoundCalculatorService.swift +++ b/GoldWars/GoldWars/RoundCalculatorService.swift @@ -25,20 +25,14 @@ class RoundCalculatorService { var isCalculating = false var numberOfAttacks = 0 var numberOfOwnUnitMoves = 0 - var roundNr = 1 func calculateRound() { - roundNr += 1 - print("roundNR \(roundNr)") - - print("entered syncingSt in calculateRound") StateManager.sharedInstance.changeState(wantedState: .syncingSt) - os_log("Started calculating Round", log: RoundCalculatorService.LOG, type: .info) + roundNr += 1 isCalculating = true let currentSnapshotModel = DataService.sharedInstance.snapshotModel - var baseSpecificMoves = collectBaseSpecificMoves() // TODO: Refactor to a less complex way @@ -177,7 +171,6 @@ class RoundCalculatorService { entityManager.updateSnapshotModel(snapshotModel: currentSnapshotModel!) entityManager.getHUD()?.startWithDuration() os_log("Finished calculating Round", log: RoundCalculatorService.LOG, type: .info) - print("entered gameSt in calculateRound") StateManager.sharedInstance.changeState(wantedState: .gameSt) } diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index 32dc733..d2988f4 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -73,9 +73,6 @@ class GameScene: SKScene{ override func update(_ currentTime: TimeInterval) { StateManager.sharedInstance.stateMachine!.update(deltaTime: currentTime) - /* entityManager.getBackground()?.update(deltaTime: currentTime) - entityManager.getHUD()?.component(ofType: TimerComponent.self)?.update() - */ } func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set, event: UIEvent?, entity: GKEntity){ diff --git a/GoldWars/GoldWars/Scenes/MenuScene.swift b/GoldWars/GoldWars/Scenes/MenuScene.swift index 7e45358..0e7c00d 100644 --- a/GoldWars/GoldWars/Scenes/MenuScene.swift +++ b/GoldWars/GoldWars/Scenes/MenuScene.swift @@ -26,7 +26,6 @@ class MenuScene: SKScene { onButtonPress: { if CommandLine.arguments.contains("--no-matchmaking") { StateManager.sharedInstance.changeState(wantedState: .gameSt) - /*self.loadScene(scene: GameScene(size: self.size))*/ SoundManager.sharedInstance.stopMenuMusic() } else { if GameCenterManager.isAuthenticated { @@ -71,16 +70,6 @@ class MenuScene: SKScene { override func update(_ currentTime: TimeInterval) { StateManager.sharedInstance.stateMachine!.update(deltaTime: currentTime) - /* - if entityManager.entities.count != 0 { - entityManager.getBackground()!.update(deltaTime: currentTime) - entityManager.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterManager.isAuthenticated - } - - if GameCenterManager.sharedInstance.initIsFinish { - self.loadScene(scene: GameCenterManager.sharedInstance.gameScene!) - } - */ } } diff --git a/GoldWars/GoldWars/States/GameState.swift b/GoldWars/GoldWars/States/GameState.swift index 6ca3e5a..f453cbc 100644 --- a/GoldWars/GoldWars/States/GameState.swift +++ b/GoldWars/GoldWars/States/GameState.swift @@ -12,7 +12,7 @@ import os class GameState: GKState { let LOG = OSLog.init(subsystem: "GameState", category: "GameState") - var aufruf = 0 + var roundNr = RoundCalculatorService.sharedInstance.roundNr override func isValidNextState(_ stateClass: AnyClass) -> Bool { return stateClass is SyncingState.Type @@ -20,13 +20,12 @@ class GameState: GKState { override func didEnter(from previousState: GKState?) { os_log("Entered Game State", log: LOG, type: .info) - if CommandLine.arguments.contains("--no-matchmaking") { + if CommandLine.arguments.contains("--no-matchmaking"){ StateManager.sharedInstance.menuSc!.loadScene(scene: GameScene(size: StateManager.sharedInstance.menuSc!.size)) } - if aufruf == 0{ + if roundNr == 1{ StateManager.sharedInstance.menuSc!.loadScene(scene: StateManager.sharedInstance.gameSc!) } - aufruf += 1 } override func update(deltaTime seconds: TimeInterval) { diff --git a/GoldWars/GoldWars/States/MenuState.swift b/GoldWars/GoldWars/States/MenuState.swift index fb8c4a4..16fb004 100644 --- a/GoldWars/GoldWars/States/MenuState.swift +++ b/GoldWars/GoldWars/States/MenuState.swift @@ -26,12 +26,6 @@ class MenuState: GKState { menuEM.getBackground()!.update(deltaTime: seconds) menuEM.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterManager.isAuthenticated } - - // if GameCenterManager.sharedInstance.initIsFinish { - // StateManager.sharedInstance.menuSc!.loadScene(scene: GameCenterManager.sharedInstance.gameScene!) - // } - - } override func didEnter(from previousState: GKState?) { diff --git a/GoldWars/GoldWars/States/StateManager.swift b/GoldWars/GoldWars/States/StateManager.swift index b441f6e..7065981 100644 --- a/GoldWars/GoldWars/States/StateManager.swift +++ b/GoldWars/GoldWars/States/StateManager.swift @@ -82,13 +82,6 @@ class StateManager{ stateMachine = GKStateMachine(states: [menuSt, syncingSt, playingSt, endGameSt]) } - /* func changeState(wantedState: StateTypes, menuSc: MenuScene?, gameVC: GameViewController?){ - self.wantedState = wantedState - self.menuSc = menuSc - self.gameVC = gameVC - enterState() - }*/ - func changeState(wantedState: StateTypes){ self.wantedState = wantedState enterState()