From 9ec6a252ee41692b844f0acb191fcbe00529d603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chauntalle=20Schu=CC=88le?= Date: Tue, 2 Jun 2020 23:04:21 +0200 Subject: [PATCH] changes after review --- GoldWars/GoldWars/GameViewController.swift | 1 - GoldWars/GoldWars/States/EndGameState.swift | 4 ++-- GoldWars/GoldWars/States/GameState.swift | 4 ++-- GoldWars/GoldWars/States/MenuState.swift | 6 +++--- GoldWars/GoldWars/States/SyncingState.swift | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/GoldWars/GoldWars/GameViewController.swift b/GoldWars/GoldWars/GameViewController.swift index 3d3046e..205500d 100644 --- a/GoldWars/GoldWars/GameViewController.swift +++ b/GoldWars/GoldWars/GameViewController.swift @@ -6,7 +6,6 @@ // Copyright © 2020 SP2. All rights reserved. // -import UIKit import SpriteKit import GameplayKit diff --git a/GoldWars/GoldWars/States/EndGameState.swift b/GoldWars/GoldWars/States/EndGameState.swift index ed9933a..791115d 100644 --- a/GoldWars/GoldWars/States/EndGameState.swift +++ b/GoldWars/GoldWars/States/EndGameState.swift @@ -14,11 +14,11 @@ class EndGameState: GKState { let LOG = OSLog.init(subsystem: "EndGameState", category: "EndGameState") override func isValidNextState(_ stateClass: AnyClass) -> Bool { - if StateManager.sharedInstance.stateMachine?.currentState is EndGameState && stateClass is EndGameState.Type{ + if stateMachine?.currentState is EndGameState && stateClass is EndGameState.Type { os_log("Already in EndGame State", log: LOG, type: .info) return false } - if stateClass is SyncingState.Type || stateClass is GameState.Type{ + if stateClass is SyncingState.Type || stateClass is GameState.Type { os_log("Failed: Entering SyncingState and GameState after EndGameState is not allowed", log: LOG, type: .info) return false } diff --git a/GoldWars/GoldWars/States/GameState.swift b/GoldWars/GoldWars/States/GameState.swift index 320ed8c..45de27a 100644 --- a/GoldWars/GoldWars/States/GameState.swift +++ b/GoldWars/GoldWars/States/GameState.swift @@ -14,11 +14,11 @@ class GameState: GKState { let LOG = OSLog.init(subsystem: "GameState", category: "GameState") override func isValidNextState(_ stateClass: AnyClass) -> Bool { - if StateManager.sharedInstance.stateMachine?.currentState is GameState && stateClass is GameState.Type{ + if stateMachine?.currentState is GameState && stateClass is GameState.Type { os_log("Already in Game State", log: LOG, type: .info) return false } - if stateClass is MenuState.Type || stateClass is EndGameState.Type{ + if stateClass is MenuState.Type || stateClass is EndGameState.Type { os_log("Failed: Entering MenuState and EndgameState after GameState is not allowed", log: LOG, type: .info) return false } diff --git a/GoldWars/GoldWars/States/MenuState.swift b/GoldWars/GoldWars/States/MenuState.swift index 95d3b25..0db4e16 100644 --- a/GoldWars/GoldWars/States/MenuState.swift +++ b/GoldWars/GoldWars/States/MenuState.swift @@ -14,11 +14,11 @@ class MenuState: GKState { let LOG = OSLog.init(subsystem: "MenuState", category: "MenuState") override func isValidNextState(_ stateClass: AnyClass) -> Bool { - if StateManager.sharedInstance.stateMachine?.currentState is MenuState && stateClass is MenuState.Type{ + if stateMachine?.currentState is MenuState && stateClass is MenuState.Type { os_log("Already in Menu State", log: LOG, type: .info) return false } - if stateClass is EndGameState.Type{ + if stateClass is EndGameState.Type { os_log("Entering EndGameState after MenuState is not allowed", log: LOG, type: .info) return false } @@ -37,7 +37,7 @@ class MenuState: GKState { override func didEnter(from previousState: GKState?) { os_log("Entered Menu State", log: LOG, type: .info) - + // UIApplication.shared.windows[0].rootViewController if (previousState == nil){ if let view = StateManager.sharedInstance.gameVC!.view as! SKView? { let scene = MenuScene(size: StateManager.sharedInstance.gameVC!.view.bounds.size) diff --git a/GoldWars/GoldWars/States/SyncingState.swift b/GoldWars/GoldWars/States/SyncingState.swift index 5cf6f2e..d4a3485 100644 --- a/GoldWars/GoldWars/States/SyncingState.swift +++ b/GoldWars/GoldWars/States/SyncingState.swift @@ -15,7 +15,7 @@ class SyncingState: GKState { var previousState: GKState? override func isValidNextState(_ stateClass: AnyClass) -> Bool { - if StateManager.sharedInstance.stateMachine?.currentState is SyncingState && stateClass is SyncingState.Type{ + if stateMachine?.currentState is SyncingState && stateClass is SyncingState.Type { os_log("Already in Syncing State", log: LOG, type: .info) return false }