/// <summary> /// Updates the state of the game. This method checks the GameScreen.IsActive /// property, so the game will stop updating when the pause menu is active, /// or if you tab away to a different application. /// </summary> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, false); // Gradually fade in or out depending on whether we are covered by the pause screen. if (coveredByOtherScreen) pauseAlpha = Math.Min(pauseAlpha + 1f / 32, 1); else pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0); // Bail early if this isn't the active screen. if (!IsActive) return; Launcher launcher = simulation.Launcher; launcher.AdjustAngle((float)Math.PI / 64 * launcherChange.X); launcher.AdjustMagnitude(0.25f * launcherChange.Y); // Update the simulation's state. simulation.Step((float)gameTime.ElapsedGameTime.TotalSeconds); if (simulation.CurrentState == SimulationState.Failed) { MessageBoxScreen failedMessageBox = new MessageBoxScreen(TopLevel, "Level Failed. Please try again.", "Retry", "Main Menu", "Level Select"); failedMessageBox.MiddleButton += MainMenuMessageBoxAccepted; failedMessageBox.LeftButton += ConfirmRetryBoxAccepted; failedMessageBox.RightButton += ConfirmLevelMessageBoxAccepted; ScreenList.AddScreen(failedMessageBox); } }
/// <summary> /// When the user cancels the main menu, ask if they want to exit the sample. /// </summary> void OnCancel() { const string message = "Are you sure you want to exit the game?"; MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(TopLevel, message); confirmExitMessageBox.RightButton += ConfirmExitMessageBoxAccepted; ScreenList.AddScreen(confirmExitMessageBox); }
/// <summary> /// Event handler for when the Restart level editor menu entry is selected. /// </summary> void RestartLevelEditorMenuEntrySelected() { string message = "Are you sure you want to restart the editor?"; if (!EditorMode) { message = "Are you sure you want to go to the editor?"; } MessageBoxScreen confirmRestartLevelEditorMessageBox = new MessageBoxScreen(TopLevel, message); confirmRestartLevelEditorMessageBox.RightButton += ConfirmRestartLevelEditorBoxAccepted; ScreenList.AddScreen(confirmRestartLevelEditorMessageBox); }
/// <summary> /// Event handler for when the Retry Game menu entry is selected. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void RestartLevelMenuEntrySelected() { // Put what happens when the person clicks retry const string message = "Are you sure you want to restart this level?"; MessageBoxScreen confirmRestartLevelMessageBox = new MessageBoxScreen(TopLevel, message); confirmRestartLevelMessageBox.RightButton += ConfirmRestartLevelBoxAccepted; ScreenList.AddScreen(confirmRestartLevelMessageBox); }
/// <summary> /// Event handler for when the Quit Game menu entry is selected. /// </summary> void QuitGameMenuEntrySelected() { const string message = "Are you sure you want to quit this level?"; MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(TopLevel, message); confirmQuitMessageBox.RightButton += ConfirmQuitMessageBoxAccepted; ScreenList.AddScreen(confirmQuitMessageBox); }