/// <summary> /// Initializes the game. /// </summary> void InitGame() { Drawer initGame = new Drawer(); initGame.gamePresets = new GamePresets(3, 0); initGame.Show(); Close(); }
/// <summary> /// Handles the end of the game. /// </summary> /// <param name="status">The status.</param> private void GameOver(string status) { if (status == "fail") { movingTimer.Stop(); MessageBox.Show("You've failed.", "Game Over"); gameOver = false; gameOverStatus = null; if (CheckHighScores(scoreValue)) { HighScores(scoreValue); Close(); } else { MapSelection returnToMap = new MapSelection(); returnToMap.Show(); Close(); } } else if (status == "success") { movingTimer.Stop(); MessageBox.Show("You've succeeded.", "Game Over"); gameOver = false; gameOverStatus = null; if (optionsSettings.MapNumber < mapMaxNumber) { if (MessageBox.Show("You've succeeded. \n Would you like to continue.", "Game Over", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { try { XDocument settingsFromXml = XDocument.Load(@"..\..\Resources\OptionsSettings.xml"); var readDataFromXml = settingsFromXml.Descendants("option"); var fromXml = from x in readDataFromXml select x; // Load the values stored in the xml. fromXml.Single().Element("map").Value = (optionsSettings.MapNumber + 1).ToString(); // Sets the number of the map to the xml for later use. settingsFromXml.Save(@"..\..\Resources\OptionsSettings.xml"); // Save the changes in the values of the xml. } catch { } Drawer newMap = new Drawer(); newMap.gamePresets = new GamePresets(lifePoint, scoreValue); newMap.Show(); Close(); } else { if (CheckHighScores(scoreValue)) { HighScores(scoreValue); Close(); } else { MapSelection returnToMap = new MapSelection(); returnToMap.Show(); Close(); } } } else { if (CheckHighScores(scoreValue)) { HighScores(scoreValue); Close(); } else { MapSelection returnToMap = new MapSelection(); returnToMap.Show(); Close(); } } } }