示例#1
0
    /// <name>
    /// OnEnable
    /// </name>
    /// <summary>
    /// Called when the object becomes enabled and active,
    /// aka every time the scene is loaded
    /// </summary>
    /// <author>
    /// Sabrina Hemming
    /// </author>
    /// <date>
    /// 4/23/18
    /// </date>
    void OnEnable()
    {
        // load player info into savedGameData to transfer into different mini games
        gameStats = gameStatsGO.GetComponent <GlobalControl> ();
        gameStats.LoadPlayer();

        // displays any incentives or stars earned by the player
        SetExtras();

        // if player has already made progress in the game, seen the instructions, or completed a game
        // don't show the instructions automatically
        if (!gameStats.IsGameStarted() && !gameStats.savedGameData.instructionsShown && gameStats.savedGameData.gamesCompleted == 0)
        {
            instructions.SetActive(true);
            blackOutSheet.SetActive(true);
            gameStats.savedGameData.instructionsShown = true;
            gameStats.SavePlayer();
            FreezePlayer();
        }

        // if player has completed all the mini games and hasn't been prompted to reset their progress, prompt them
        // if they have ever been prompted, they are not ever prompted again.
        if (gameStats.IsGameComplete() && !gameStats.savedGameData.resetPromptShown)
        {
            resetPrompt.SetActive(true);
            resetPrompt.GetComponentInChildren <Text> ().text = "Would you like to reset your game? All of your game scores will be " +
                                                                "reset to zero and you will earn a star. Your timed challenge progress will not be erased.";
            blackOutSheet.SetActive(true);
            gameStats.savedGameData.resetPromptShown = true;
            gameStats.SavePlayer();
            FreezePlayer();
        }
    }
示例#2
0
    /* 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);
    }
示例#3
0
    /* 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();
    }
    /* void CheckAnswer() */

    /// <name>
    /// ExitGame
    /// </name>
    /// <summary>
    /// Save game data and return to the welcome screen of the main menu
    /// </summary>
    /// <author>
    /// Sabrina Hemming
    /// </author>
    /// <date>
    /// 4/20/18
    /// </date>
    private void ExitGame()
    {
        gameStats.SavePlayer();
        SceneManager.LoadScene(Constants.SceneNames.MAIN_AREA);
    }