/* private void StartGame() */ /// <name> /// EndGame /// </name> /// <summary> /// When the timer runs out the player gets to see the results /// </summary> /// <author> /// Sabrina Hemming /// </author> /// <date> /// 4/22/18 /// </date> private void EndGame() { // show end game screen startScreen.SetActive(false); gameScreen.SetActive(false); chooseLevelScreen.SetActive(false); endGameScreen.SetActive(true); // check if user beat their high score if (correctAnswers > highScore) { newHighScoreMessage.SetActive(true); // store new high score (both in game and for save file) highScore = correctAnswers; SetStoredHighScore(); gameStats.SavePlayer(); GlobalControl.Save(); } else { // turn off the message that says player got a high score newHighScoreMessage.SetActive(false); } // display the score earned finalScore.text = "Score: " + correctAnswers.ToString(); // display the high score gameOverHighScore.text = "High Score: " + highScore.ToString(); }
/* private void ContinueGame() */ /// <name> /// SaveAndContinue /// </name> /// <summary> /// Confirm valid game name and then start the game /// </summary> /// <author> /// Sabrina Hemming /// </author> /// <date> /// 4/16/18 /// </date> private void SaveAndContinue() { Text errorMsg = GameObject.Find(Constants.MainMenu.ERROR_TEXT_GO).GetComponent <Text>(); string filename = userSaveNameInput.text; // make sure there are no unacceptable characters in user input if (IsValidGameName(filename)) { string path = Application.persistentDataPath + "/" + filename + Constants.MainMenu.FILE_EXTENSION; // checks if there is a file with the save name already in the directory if (!File.Exists(path)) { // start a new game in case player just exited a different game GlobalControl.Instance.savedGameData = new Game(); // saves file and loads the main area to begin playing GlobalControl.Save(filename); SceneManager.LoadScene(Constants.SceneNames.MAIN_AREA); } else { errorMsg.text = Constants.MainMenu.Error.EXISTS; } } else { // display error message to user errorMsg.text = Constants.MainMenu.Error.GENERIC; } }
/* public void CheckProgress() */ /// <name> /// SaveQuit /// </name> /// <summary> /// Saves user's progress and returns to the main menu /// </summary> /// <author> /// Sabrina Hemming /// </author> /// <date> /// 4/24/18 /// </date> private void SaveQuit() { // if they haven't made any progess, have instructions show when // they come back to play if (!gameManager.IsGameStarted()) { gameManager.savedGameData.instructionsShown = false; } gameManager.SavePlayer(); GlobalControl.Save(); SceneManager.LoadScene(Constants.SceneNames.MAIN_MENU); }
/* public void SetTimedText() */ /// <name> /// ResetGame /// </name> /// <summary> /// Either resets game or allows user to back out of resetting game /// </summary> /// <param name="response">user's response to resetting the game. controlled by button input</param> /// <author> /// Sabrina Hemming /// </author> /// <date> /// 4/27/18 /// </date> public void ResetGame(string response) { // make the prompt pop up go away GameObject promptScreen = GameObject.Find("ConfirmResetScreen"); promptScreen.SetActive(false); // reset progress or leave as is depending on the user's response if (response.ToLower() == "yes") { // make the number of correct answers of all mini games 0, // all levels of all mini games zero gameManager.savedGameData.addition.correctAnswers = 0; gameManager.savedGameData.addition.level = 1; gameManager.savedGameData.subtraction.correctAnswers = 0; gameManager.savedGameData.subtraction.level = 1; gameManager.savedGameData.counting.correctAnswers = 0; gameManager.savedGameData.counting.level = 1; gameManager.savedGameData.equality.correctAnswers = 0; gameManager.savedGameData.equality.level = 1; // increase the count of number of games completed gameManager.savedGameData.gamesCompleted++; // save the reset gameManager.SavePlayer(); GlobalControl.Save(); // tell user that their data has been reset Text result = resetResultScreen.GetComponentInChildren <Text> (); result.text = "Your game has been reset! You have been awarded a star for starting a new game."; // clears any incentives visible in the main area and adds a star for a completed game incentiveDisplayScript.SetExtras(); resetResultScreen.SetActive(true); } else { // display message that no changes have been made to the save data Text result = resetResultScreen.GetComponentInChildren <Text> (); result.text = "Your progress has not been changed. Check back in the main menu if you change your mind!"; resetResultScreen.SetActive(true); } }
/* private void SaveQuit() */ /// <name> /// Challenge /// </name> /// <summary> /// Goes to the main menu of the timed challenges /// </summary> /// <author> /// Sabrina Hemming /// </author> /// <date> /// 4/24/18 /// </date> private void Challenge() { gameManager.SavePlayer(); GlobalControl.Save(); SceneManager.LoadScene(Constants.SceneNames.CHALLENGE); }