Example #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();
        }
    }
    /* 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);
    }