public static void CancelQuit() { if (_quitState == QuitState.BeforeQuit) { _quitState = QuitState.None; } }
/// <summary> /// Preferred method of closing application. /// </summary> public static void QuitApplication() { if (_quitState == QuitState.None) { _quitState = QuitState.BeforeQuit; if (BeforeApplicationQuit != null) { BeforeApplicationQuit(_instance, System.EventArgs.Empty); } if (_quitState == QuitState.BeforeQuit) { //wasn't cancelled, or force quit if (UnityEngine.Application.isEditor) { try { var tp = com.spacepuppy.Utils.TypeUtil.FindType("UnityEditor.EditorApplication"); tp.GetProperty("isPlaying").SetValue(null, false, null); } catch { UnityEngine.Debug.Log("Failed to stop play in editor."); } } else { UnityEngine.Application.Quit(); } } } }
private void OnApplicationQuit() { _quitState = QuitState.Quit; if (ApplicatinQuit != null) { ApplicatinQuit(this, System.EventArgs.Empty); } }
void initState() { netStateMachine = new GameStateMachine(); GameState state = new PreConnectState(); netStateMachine.addState(state); state = new ConnectState(); netStateMachine.addState(state); state = new ReconnectState(); netStateMachine.addState(state); state = new ReloginState(); netStateMachine.addState(state); state = new RunState(); netStateMachine.addState(state); state = new QuitState(); netStateMachine.addState(state); }
/// <summary> /// Implements the logic to terminate the desktop, including closing all windows and terminating the session. /// </summary> /// <returns>True if the application is really going to terminate, false otherwise.</returns> private void DoQuit(bool force) { if (IsQuitting) { return; } PhoneHome.ShutDown(); if (!force) { _quitState = QuitState.QuittingNormally; if (!CloseAllWindows()) { _quitState = QuitState.NotQuitting; return; } // send quitting event QuittingEventArgs args = new QuittingEventArgs(); OnQuitting(args); // ensure the action model is disposed - this will cause it to be written out to the store ActionModelSettings.Default.Dispose(); } else { _quitState = QuitState.QuittingForcefully; } try { SessionManager.Current.TerminateSession(); } catch (Exception e) { Platform.Log(LogLevel.Error, e); } // shut down the GUI message loop TerminateGuiToolkit(); }
/// <summary> /// Implements the logic to terminate the desktop, including closing all windows and terminating the session. /// </summary> /// <returns>True if the application is really going to terminate, false otherwise.</returns> private void DoQuit(bool force) { if (IsQuitting) { return; } PhoneHome.ShutDown(); if (!force) { _quitState = QuitState.QuittingNormally; if (!CloseAllWindows()) { _quitState = QuitState.NotQuitting; return; } // send quitting event QuittingEventArgs args = new QuittingEventArgs(); OnQuitting(args); } else { _quitState = QuitState.QuittingForcefully; } try { SessionManager.Current.TerminateSession(); } catch (Exception e) { Platform.Log(LogLevel.Error, e); } // shut down the GUI message loop TerminateGuiToolkit(); }
public static void ChangeToState(GameStates state) { switch (state) { case GameStates.MainMenuState: CurrentState = new MainMenuState(currentScreenSize); break; case GameStates.LevelOneState: CurrentState = new LevelOneState(content, currentScreenSize); break; case GameStates.LevelTwoState: CurrentState = new LevelTwoState(content, currentScreenSize); break; case GameStates.LevelThreeState: CurrentState = new LevelThreeState(content, currentScreenSize); break; case GameStates.FinalLevel: CurrentState = new FinalLevel(content, currentScreenSize); break; case GameStates.Quit: CurrentState = new QuitState(currentScreenSize); break; case GameStates.PickName: CurrentState = new PickNameState(currentScreenSize); break; case GameStates.HighScore: CurrentState = new HighScoreState(currentScreenSize); break; } if (UnSeriousEngine.isInitialized) { CurrentState.LoadContent(Content); } }