public void PopStateStack() { if (stateStack.Count == 0) { Debug.Log("PopStateStack has no state to remove."); curStateObj = new StateNormal(); IGameState obj = curStateObj; inputHandler = obj.InputHandler; GameState = GameState.Normal; } else { if (curStateObj != null) { Debug.Log("PopStateStack - Calling OnLeaveState"); curStateObj.OnLeaveState(); curStateObj = null; } StateEntry stateEntry = stateStack.Pop(); inputHandler = stateEntry.InputHandler; GameState = stateEntry.State; curStateObj = stateEntry.StateObject; if (curStateObj != null) { curStateObj.OnRestoreState(); } Debug.Log("StateStack now has " + stateStack.Count + " entries."); } }
private void Initialize() { Logger.Log("GameSystem: Starting GameSystem"); IsInitialized = true; AssetManager = new AssetManager(); AudioController = new AudioController(); TextController = new TextController(); TextHistory = new TextHistory(); try { AssetManager.CompileIfNeeded(); Logger.Log("GameSystem: Starting ScriptInterpreter"); Type type = Type.GetType(ScriptInterpreterName); if (type == null) { throw new Exception("Cannot find class " + ScriptInterpreterName + " through reflection!"); } ScriptSystem = (Activator.CreateInstance(type) as IScriptInterpreter); if (ScriptSystem == null) { throw new Exception("Failed to instantiate ScriptSystem!"); } ScriptSystem.Initialize(this); } catch (Exception arg) { Logger.LogError($"Unable to load Script Interpreter of type {ScriptInterpreterName}!\r\n{arg}"); throw; IL_00d0 :; } IsRunning = true; GameState = GameState.Normal; curStateObj = new StateNormal(); IGameState obj = curStateObj; inputHandler = obj.InputHandler; MessageBoxVisible = false; if (!PlayerPrefs.HasKey("width")) { PlayerPrefs.SetInt("width", 640); } if (!PlayerPrefs.HasKey("height")) { PlayerPrefs.SetInt("height", 480); } if (PlayerPrefs.GetInt("width") < 640) { PlayerPrefs.SetInt("width", 640); } if (PlayerPrefs.GetInt("height") < 480) { PlayerPrefs.SetInt("height", 480); } if ((Screen.width < 640 || Screen.height < 480) && !Screen.fullScreen) { Screen.SetResolution(640, 480, fullscreen: false); } }
public void ForceReturnNormalState() { stateStack.Clear(); curStateObj = new StateNormal(); IGameState obj = curStateObj; inputHandler = obj.InputHandler; GameState = GameState.Normal; }
public void LeaveConfigScreen(ConfigManager.LeaveConfigDelegate callback) { inputHandler = null; configManager.Leave(delegate { PopStateStack(); ExecuteActions(); if (callback != null) { callback(); } }); }
private void PushStateStack(MGHelper.InputHandler newHandler, GameState newState) { if (curStateObj != null) { stateStack.Push(new StateEntry(curStateObj, GameState)); } else { stateStack.Push(new StateEntry(inputHandler, GameState)); } inputHandler = newHandler; GameState = newState; curStateObj = null; }
public void PushStateObject(IGameState stateObject) { if (curStateObj != null) { stateStack.Push(new StateEntry(curStateObj, GameState)); } else { stateStack.Push(new StateEntry(inputHandler, GameState)); } curStateObj = stateObject; IGameState obj = curStateObj; inputHandler = obj.InputHandler; GameState = curStateObj.GetStateType(); }
public void LeaveGalleryScreen(GalleryManager.GalleryCloseCallback callback) { if (!(galleryManager == null)) { inputHandler = null; galleryManager.Close(delegate { PopStateStack(); ExecuteActions(); galleryManager = null; if (callback != null) { callback(); } }); } }
public StateEntry(IGameState stateobj, GameState state) { StateObject = stateobj; InputHandler = stateobj.InputHandler; State = state; }
public StateEntry(MGHelper.InputHandler inputHandler, GameState state) { InputHandler = inputHandler; State = state; }