/// <name>
    /// Start
    /// </name>
    /// <summary>
    /// Use this for initialization
    /// </summary>
    /// <author>
    /// Sabrina Hemming
    /// </author>
    /// <date>
    /// 2/12/18
    /// </date>
    void Start()
    {
        // get access to script on Chest and Coin object to play it's animation
        coinScript  = coinGO.GetComponent <PlayAnimation> ();
        chestScript = chestGO.GetComponent <PlayAnimation> ();

        // get access to saved addition game info to update
        gameStats    = gameStatsGO.GetComponent <GlobalControl> ();
        additionGame = gameStats.savedGameData.addition;

        // add a listener for when user clicks enter button
        enterButton
        .onClick
        .AddListener(CheckAnswer);

        // add a listener for when user clicks exit button
        exitButton
        .onClick
        .AddListener(ExitGame);

        // get the input field as a game object and an input field object
        GameObject inputFieldGO = GameObject.Find(Constants.INPUT);

        InputFieldCO = inputFieldGO.GetComponent <InputField> ();

        isFocused = false;


        score.text = additionGame.correctAnswers.ToString();

        // get the first math equation and set the text
        equation         = new MathEquation(additionGame.increaseRange, additionGame.level, MathEquation.EquationType.Addition);
        mathProblem.text = equation.EquationString;
    }
        public Task <StartRoundResult> StartNewRound(MathEquation equation)
        {
            lock (_lock)
            {
                if (CurrentState == GameState.RoundInPlay)
                {
                    throw new InvalidOperationException("Cannot start new round when previous round is in play");
                }

                var gamePlayers = Players.ToArray();

                if (!gamePlayers.Any())
                {
                    var gameState = UpdateRoundStatus();

                    return(Task.FromResult(new StartRoundResult(gameState.State, CurrentRound)));
                }

                CurrentRound = new GameRound(Guid.NewGuid(), _dateTimeProvider.UtcNow, equation, gamePlayers);
                CurrentState = GameState.RoundInPlay;

                var state = UpdateRoundStatus();

                return(Task.FromResult(new StartRoundResult(state.State, CurrentRound)));
            }
        }
Exemple #3
0
        public void Test_KnownEquations()
        {
            foreach (var tup in KnownEquations) //< Part one tests
            {
                var eqn = new MathEquation(tup.Item1);
                Assert.IsTrue(eqn.Result == tup.Item2);
            }

            foreach (var tup in KnownPrecedenceEquations) //< Part two tests
            {
                var eqn = new MathEquation(tup.Item1, HomeworkType.Advanced);
                Assert.IsTrue(eqn.Result == tup.Item2);
            }
        }
Exemple #4
0
        public void SolveEquation_CIsZero_ReturnsZeroAndOtherRoot()
        {
            //arrange
            double a = 10, b = 2, c = 0;

            double[] expected = { 0, (double)-4 / 20 };

            //act
            MathEquation equation = new MathEquation(a, b, c);

            double[] actual = equation.SolveEquation();

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #5
0
        public void SolveEquation_BIsZeroAndRootsExist_ReturnsTwoRoots()
        {
            //arrange
            double a = 7, b = 0, c = -7;

            double[] expected = { 1, -1 };

            //act
            MathEquation equation = new MathEquation(a, b, c);

            double[] actual = equation.SolveEquation();

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #6
0
        public void SolveEquation_AIsZero_ReturnsOneRoot()
        {
            //arrange
            double a = 0, b = 7, c = -9;

            double[] expected = { (double)9 / 7 };

            //act
            MathEquation equation = new MathEquation(a, b, c);

            double[] actual = equation.SolveEquation();

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #7
0
        public void SolveEquation_AllCoefficientsAreZero_ReturnsEmptyArray()
        {
            //arrange
            double a = 0, b = 0, c = 0;

            double[] expected = { };

            //act
            MathEquation equation = new MathEquation(a, b, c);

            double[] actual = equation.SolveEquation();

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #8
0
        public void SolveEquation_AllCoefficientsAreNotZeroAndRootsDontExist_ReturnsEmptyArray()
        {
            //arrange
            double a = 6, b = 0.1, c = 53;

            double[] expected = { };

            //act
            MathEquation equation = new MathEquation(a, b, c);

            double[] actual = equation.SolveEquation();

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #9
0
        public void SolveEquation_BAndCAreZero_ReturnsZero()
        {
            //arrange
            double a = 1.056, b = 0, c = 0;

            double[] expected = { 0 };

            //act
            MathEquation equation = new MathEquation(a, b, c);

            double[] actual = equation.SolveEquation();

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #10
0
        public void SolveEquation_AllCoefficientsAreNotZeroAndSolutionExists_ReturnsTwoRoots()
        {
            //arrange
            double a = 3, b = -14, c = -5;

            double[] expected = { 5, (double)-1 / 3 };

            //act
            MathEquation equation = new MathEquation(a, b, c);

            double[] actual = equation.SolveEquation();

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #11
0
    /* void Update() */

    /// <name>
    /// StartGame
    /// </name>
    /// <summary>
    /// Sets up screen to start timed game and initializes equation
    /// </summary>
    /// <author>
    /// Sabrina Hemming
    /// </author>
    /// <date>
    /// 4/22/18
    /// </date>
    private void StartGame()
    {
        // show screen to start game
        gameScreen.SetActive(true);
        startScreen.SetActive(false);
        chooseLevelScreen.SetActive(false);

        // create equation based on user's choices and set display string
        equation         = new MathEquation(10, level, equationType);
        mathProblem.text = equation.EquationString;

        // find high score for current game and display it to the user
        GetHighScore();
        gameHighScore.text = highScore.ToString();

        // sets the timer and has the UpdateTimer function called every half second
        timer          = Constants.TimedChallenge.CurrentGameGO.TIMER_VALUE;
        timerText.text = "Time: 1:00";
        InvokeRepeating("UpdateTimer", 0.0f, Constants.TimedChallenge.CurrentGameGO.TIMER_REFRESH_RATE);
    }