Beispiel #1
0
    /* private void PlayAgain() */

    /// <name>
    /// SetEquationType
    /// </name>
    /// <summary>
    /// Sets the type of the equation and sets scene to have user pick difficulty
    /// level - used with equation type buttons.
    /// </summary>
    /// <param name="eqType">The equation type the user wants to solve - addition, subtraction.</param>
    /// <author>
    /// Sabrina Hemming
    /// </author>
    /// <date>
    /// 4/22/18
    /// </date>
    private void SetEquationType(MathEquation.EquationType eqType)
    {
        equationType = eqType;

        // show screen to pick difficulty level
        startScreen.SetActive(false);
        gameScreen.SetActive(false);
        endGameScreen.SetActive(false);
        chooseLevelScreen.SetActive(true);
    }
Beispiel #2
0
    /// <name>
    /// Start
    /// </name>
    /// <summary>
    /// Used for initialization
    /// </summary>
    /// <author>
    /// Sabrina Hemming
    /// </author>
    /// <date>
    /// 4/22/18
    /// </date>
    void Start()
    {
        // used to set if the player wants to do addition or subtraction
        additionGame
        .onClick
        .AddListener(delegate { SetEquationType(MathEquation.EquationType.Addition); });

        subtractionGame
        .onClick
        .AddListener(delegate { SetEquationType(MathEquation.EquationType.Subtraction); });

        backButton
        .onClick
        .AddListener(SwitchToStoryMode);

        // used to set the level of difficulty of the problems given
        level1
        .onClick
        .AddListener(delegate { SetLevel(1); });

        level2
        .onClick
        .AddListener(delegate { SetLevel(2); });

        level3
        .onClick
        .AddListener(delegate { SetLevel(3); });

        // user can click to enter the answer for an equation
        submitAnswer
        .onClick
        .AddListener(CheckAnswer);

        // brings user to the main menu to choose to continue a game
        // or start a new one
        exitButton
        .onClick
        .AddListener(ExitToMainMenu);

        // brings the user to the main area where they can pick mini games
        storyModeButton
        .onClick
        .AddListener(SwitchToStoryMode);

        // brings user through menus to pick equation type and difficulty
        replayButton
        .onClick
        .AddListener(PlayAgain);


        // get the text/GO elements for game over screen
        gameOverHighScore   = GameObject.Find(Constants.TimedChallenge.GameOverGO.HIGH_SCORE).GetComponent <Text>();
        newHighScoreMessage = GameObject.Find(Constants.TimedChallenge.GameOverGO.NEW_HIGH_SCORE_MSG_GO);
        finalScore          = GameObject.Find(Constants.TimedChallenge.GameOverGO.FINAL_SCORE).GetComponent <Text> ();

        // get the text/GO elements for the current game screen
        currentScore      = GameObject.Find(Constants.TimedChallenge.CurrentGameGO.CURRENT_SCORE).GetComponent <Text> ();
        currentScore.text = correctAnswers.ToString();
        gameHighScore     = GameObject.Find(Constants.TimedChallenge.CurrentGameGO.HIGH_SCORE).GetComponent <Text> ();
        inputFieldCO      = GameObject.Find(Constants.INPUT).GetComponent <InputField> ();

        // get references to the different views used in this scene
        gameScreen        = GameObject.Find(Constants.TimedChallenge.Views.GAME_SCREEN);
        startScreen       = GameObject.Find(Constants.TimedChallenge.Views.START_SCREEN);
        chooseLevelScreen = GameObject.Find(Constants.TimedChallenge.Views.LEVEL_SCREEN);
        endGameScreen     = GameObject.Find(Constants.TimedChallenge.Views.END_GAME_SCREEN);


        // set default values for these variables
        level          = 1;
        correctAnswers = 0;
        equationType   = MathEquation.EquationType.Addition;
        isFocused      = false;

        // turn off screens other than opening screen
        gameScreen.SetActive(false);
        chooseLevelScreen.SetActive(false);
        endGameScreen.SetActive(false);

        // get access to saved challenge game info to update
        gameStats = gameStatsGO.GetComponent <GlobalControl> ();
        highScore = gameStats.savedGameData.additionChallenge.l1HighScore;
    }