public static void FinalizeScreenCapUpdate() { // unload unused ScreenCaps Resources.UnloadUnusedAssets(); // set default GameView size ResizeGameViewToDefault(); // LiveUpdate - remove help message if it's not longer relevant if (AllScreenCapsUpdatedSuccesfull()) { xARMPreviewWindow.WarningBoxText = ""; xARMGalleryWindow.WarningBoxText = ""; } // run custom code if (OnFinalizeScreenCapUpdate != null) { OnFinalizeScreenCapUpdate(); } // close GameView after update? if (xARMManager.CurrEditorMode == EditorMode.Edit && xARMManager.Config.CloseGameViewAfterUpdate) { GameView.Close(); } }
//Checking for win situation. On "false", game continues. If no unmatched cards in a deck found, //showing the final score and asking player for another round. private void CheckForWin() { bool win = true; foreach (Card card in Deck) { if (card.matched == false) { win = false; } } if (win) { MessageBox.Show(String.Format("You matched all the icons! \nYour final score is {0}", score), "Congratulations!"); string highscore_by_tableSize = string.Format("Highscore_{0}", tableSize); if (Convert.ToInt32(Properties.Settings.Default[highscore_by_tableSize]) > score) { Properties.Settings.Default[highscore_by_tableSize] = score.ToString(); Properties.Settings.Default.Save(); string result = "New highscore on {0} is {1}"; MessageBox.Show(string.Format(result, tableSize, score), "Highscore is beaten!"); _menuView.on_NewGame(score.ToString()); } DialogResult try_again = MessageBox.Show("Try again?", ":)", MessageBoxButtons.YesNo); if (try_again == DialogResult.Yes) { _menuView.Show(); _gameView.Dispose(); } else { _gameView.Close(); } } }
public void GameEnded(string result) //"won" = 1P wins, "loss" = 2P wins, "tie" = no winner { String message = ""; if (result == "won") { message = "Congratulations to Player1 for winning! Play again?"; } if (result == "loss") { message = "Congratulations to Player2 for winning! Play again?"; } if (result == "tie") { message = "This game resulted in a tie! Play again?"; } //Normal behavior if (result != "") { DialogResult dialogResult = MessageBox.Show(message, "Game Ended", MessageBoxButtons.YesNo); switch (dialogResult) { case DialogResult.Yes: break; case DialogResult.No: _view.Close(); break; } } //The window was closed without the game finishing else { _model.ResetGameState(); } }
private void Button_Click_2(object sender, RoutedEventArgs e) => parent.Close();