public IEnumerator WHEN_SquareRoundAdded1Round_THEN_SquareRoundGetterReturnsCorrectValues()
            {
                squaresData        = new SquaresStorage();
                squaresData.Rounds = new List <SquaresRound>();
                round = new SquaresRound();

                round.SquareHighlightDuration = 5.9f; // float value
                float expectedHighlightDuration = 5.9f;

                round.SquareHighlightInterval = 7.3f; // float value
                float expectedHighlightInterval = 7.3f;

                round.RecallTime = 8.59f; // float value
                float expectedRecallTime = 8.59f;

                IndexAndPosition testIndexAndPosition = new IndexAndPosition(3, new Position2D(3, 5));

                round.HighlightedSquares = new List <IndexAndPosition>();
                round.HighlightedSquares.Add(testIndexAndPosition);
                round.RecalledSquares = new List <IndexAndPosition>();
                round.RecalledSquares.Add(testIndexAndPosition);

                squaresData.Rounds.Add(round);
                SquaresRound actualSquaresRound = squaresData.Rounds[0];

                yield return(null);

                Assert.IsTrue(expectedHighlightDuration == actualSquaresRound.SquareHighlightDuration, "");
                Assert.IsTrue(expectedHighlightInterval == actualSquaresRound.SquareHighlightInterval, "");
                Assert.IsTrue(expectedRecallTime == actualSquaresRound.RecallTime, "");
                Assert.IsTrue(testIndexAndPosition == round.RecalledSquares[0], "");
                Assert.IsTrue(testIndexAndPosition == round.HighlightedSquares[0], "");
            }
            public IEnumerator WHEN_SquareRoundCreated_THEN_RoundIsEmpty()
            {
                squaresData        = new SquaresStorage();
                squaresData.Rounds = new List <SquaresRound>();
                int expectedSizeOfList = 0;

                yield return(null);

                Assert.IsTrue(expectedSizeOfList == squaresData.Rounds.Count, "round list is not empty at creation.");
            }
Esempio n. 3
0
            public IEnumerator WHEN_GetGameplayDataFunctionCalledAtBeginning_THEN_EmptyGamePlayDataRetured()
            {
                // Test the storage right at the beginning of the game
                SquaresStorage actualSquaresStorage = Squares.GetGameplayData();

                yield return(null);

                List <SquaresRound> expectedSquaresStorage = new List <SquaresRound>();

                Assert.AreEqual(expectedSquaresStorage, actualSquaresStorage.Rounds);
            }
        /// <summary>
        /// FillAllGameData is to update game data objects with corresponding raw gameplay data.
        /// It will only get gameplay data for the games that have been played.
        /// </summary>
        public void FillAllGameData()
        {
            // Get gameplay data for Balloons
            // If the game has been played, get the gameplay data; else, skip this game
            if (!notYetPlayBalloons)
            {
                balloonsData = Balloons.GetGameplayData();
            }

            // Get gameplay data for Squares
            // If the game has been played, get the gameplay data; else, skip this game
            if (!notYetPlaySquares)
            {
                squaresData = Squares.GetGameplayData();
            }


            // Get gameplay data for Catch The Thief
            // If the game has been played, get the gameplay data; else, skip this game
            if (!notYetPlayCTF)
            {
                ctfData = CatchTheThief.GetGameplayData();
            }

            // Get gameplay data for ImageHit
            // If the game has been played, get the gameplay data; else, skip this game
            if (!notYetPlayImageHit)
            {
                imageHitData = ImageHit.GetGameplayData();
            }

            // Get gameplay data for Catch The Ball
            // If the game has been played, get the gameplay data; else, skip this game
            if (!notYetCatchTheBall)
            {
                catchTheBallData = CatchTheBall.GetGameplayData();
            }

            // Get gameplay data for Save One Ball
            // If the game has been played, get the gameplay data; else, skip this game
            if (!notYetSaveOneBall)
            {
                saveOneBallData = SaveOneBall.GetGameplayData();
            }

            // Get gameplay data for Judge The Ball
            // If the game has been played, get the gameplay data; else, skip this game
            if (!notYetJudgeTheBall)
            {
                judgeTheBallData = JudgeTheBall.GetGameplayData();
            }
        }
            public IEnumerator WHEN_SquareRoundAdded1Round_THEN_SquareRoundSizeIs1()
            {
                squaresData        = new SquaresStorage();
                squaresData.Rounds = new List <SquaresRound>();

                round = new SquaresRound();
                squaresData.Rounds.Add(round);

                int expectedSizeOfList = 1;

                yield return(null);

                Assert.IsTrue(expectedSizeOfList == squaresData.Rounds.Count, "round list does not have the added round.");
            }
            public IEnumerator WHEN_EvaluateSquaresScoreFunctionCalledOnEmptyInput_SquareSubScoreReturnsBaseScore()
            {
                // Initialize the measurement module
                InitializeVisuospatialMeasure();

                // Call the evaluate score function
                VisuospatialSketchpadMeasure.EvaluateSquaresScore();

                yield return(null);

                // SquaresStorage datatype variable to hold the data from the squares mini-game
                SquaresStorage squaresData = Squares.GetGameplayData();

                // Ensure that SubscoreSquares values are correctly set
                Assert.AreEqual(AbilityName.VISUOSPATIAL_SKETCHPAD, VisuospatialSketchpadMeasure.subScoreSquares.AbilityName);
                Assert.AreEqual(GameName.SQUARES, VisuospatialSketchpadMeasure.subScoreSquares.GameName);
                Assert.AreEqual(0, VisuospatialSketchpadMeasure.subScoreSquares.Score);
                Assert.AreEqual(2, VisuospatialSketchpadMeasure.subScoreSquares.Weight);
            }
        //Helper functions start:
        //-----------------------------------------------------------------

        /// <summary>
        /// Initializes all state variables and objects
        /// necessary for the Squares mini-game.
        /// </summary>
        private void Squares_init()
        {
            // Initialize the storage variables
            squaresData        = new SquaresStorage();
            squaresData.Rounds = new List <SquaresRound>();

            // Initialize game variables
            numberOfHighlightedSquares = STARTING_NUMBER_OF_HIGHLIGHTED_SQUARES;
            // The time between each highlight is calculated using the formula: squareHighlightInterval - squareHighlightDuration
            squareHighlightInterval = 0.7f;
            squareHighlightDuration = 0.7f;
            recallTime  = 0;
            roundNumber = 0;
            doneButton.gameObject.SetActive(false);
            totalSquareClicks = 0;

            // Set the Id value for each of the square game objects
            AssignSquareIdValue();
        }
Esempio n. 8
0
            public IEnumerator WHEN_GetGameplayDataFunctionCalled_THEN_GamePlayDataRetured()
            {
                // Wait for highlight sequence stage
                yield return(new WaitForSeconds(squareHighlightDuration * 3));

                yield return(new WaitForSeconds(0.02f));

                // Click on a square
                displayedSquares[1].GetComponent <Button>().onClick.Invoke();
                yield return(new WaitForSeconds(squareHighlightDuration));

                // End the round (And store information)
                doneButton.onClick.Invoke();
                yield return(new WaitForSeconds(0.01f));

                // Test the storage after round information is
                SquaresStorage actualSquaresStorage = Squares.GetGameplayData();

                List <IndexAndPosition> expectedRecalledSquares = new List <IndexAndPosition>();

                // The game object is displayedSquares
                Square     squareScript       = displayedSquares[1].GetComponent <Square>();
                Position2D expectedPosition2D = squareScript.Position;

                IndexAndPosition expectedIndexAndPosition = new IndexAndPosition(1, expectedPosition2D);

                expectedRecalledSquares.Add(expectedIndexAndPosition);
                double expectedRecallTime = squareHighlightDuration + 0.02;

                // Check that the information in the storage is correct
                Assert.AreEqual(3, actualSquaresStorage.Rounds[0].HighlightedSquares.Count);
                Assert.AreEqual(expectedRecalledSquares[0].Index, actualSquaresStorage.Rounds[0].RecalledSquares[0].Index);
                Assert.IsTrue(Math.Abs((expectedRecalledSquares[0].Position.X) - (actualSquaresStorage.Rounds[0].RecalledSquares[0].Position.X)) <= tolerance);
                Assert.IsTrue(Math.Abs((expectedRecalledSquares[0].Position.Y) - (actualSquaresStorage.Rounds[0].RecalledSquares[0].Position.Y)) <= tolerance);
                Assert.IsTrue(Math.Abs(actualSquaresStorage.Rounds[0].RecallTime - expectedRecallTime) <= tolerance);
                Assert.IsTrue(Math.Abs(squareHighlightInterval - actualSquaresStorage.Rounds[0].SquareHighlightInterval) <= tolerance);
                Assert.IsTrue(Math.Abs(squareHighlightDuration - actualSquaresStorage.Rounds[0].SquareHighlightDuration) <= tolerance);
            }