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], "");
            }
Ejemplo n.º 2
0
            public IEnumerator WHEN_IndexAndPositionCreated_THEN_IndexGetFunctionWorks()
            {
                tempIndexAndPosition = new IndexAndPosition(3, new Position2D(3, 5));
                tempId = tempIndexAndPosition.Index;

                yield return(null);

                Assert.AreEqual(3, tempId);
            }
Ejemplo n.º 3
0
            public IEnumerator WHEN_IndexAndPositionCreated_THEN_PositionGetFunctionWorks()
            {
                tempIndexAndPosition = new IndexAndPosition(3, new Position2D(3, 5));
                tempPosition2D       = tempIndexAndPosition.Position;

                yield return(null);

                Assert.AreEqual(3, tempPosition2D.X);
                Assert.AreEqual(5, tempPosition2D.Y);
            }
            public IEnumerator WHEN_SquaresHighlightedSquaresAdd1Item_THEN_SquaresHighlightedSquaresHas1Item()
            {
                IndexAndPosition testIndexAndPosition = new IndexAndPosition(3, new Position2D(3, 5));

                round = new SquaresRound();
                round.HighlightedSquares = new List <IndexAndPosition>();
                round.HighlightedSquares.Add(testIndexAndPosition);
                int expectedSizeOfList = 1;

                yield return(null);

                Assert.IsTrue(expectedSizeOfList == round.HighlightedSquares.Count, "When one item is added to HighlightedSquares, the size of HighlightedSquares is incorrect");
            }
            public IEnumerator WHEN_SquaresRecalledSquaresSet_THEN_SquaresRoundGetsCorrectValue()
            {
                IndexAndPosition testIndexAndPosition = new IndexAndPosition(3, new Position2D(3, 5));

                round = new SquaresRound();
                round.RecalledSquares = new List <IndexAndPosition>();
                round.RecalledSquares.Add(testIndexAndPosition);
                List <IndexAndPosition> expectedRecalledSquaresList = new List <IndexAndPosition>()
                {
                    testIndexAndPosition
                };

                yield return(null);

                Assert.IsTrue(expectedRecalledSquaresList[0] == round.RecalledSquares[0], "SquareHighlightInterval getter returning incorrect value");
            }
        /// <summary>
        /// Highlight a sequence of squares one by one with each lit up for a predetermined number of seconds.
        /// This function is type IEnumerator because it is called as a coroutine
        /// and ensures that all actions within this function execute
        /// with the correct wait duration in between.
        /// </summary>
        /// <param name="listOfSquares">The list of square game objects to highlight</param>
        /// <param name="durationToWaitBetweenHighlight">The duration of time to wait between highlights of squares</param>
        private IEnumerator HighlightSquareSequence(List <GameObject> listOfSquares, float durationToWaitBetweenHighlight)
        {
            // Go through each square that was selected for highlighting and
            // call HighlightSquare() with the index of square
            foreach (GameObject squareGameObject in listOfSquares)
            {
                // Convert the game object to a IndexAndPosition object to store in gameplay data
                squareIndexAndPosition = GameObjectToIndexAndPosition(squareGameObject);
                // Add this IndexAndPosition object to the round gamedata object
                round.HighlightedSquares.Add(squareIndexAndPosition);


                // Highlight the square
                StartCoroutine(HighlightSquare(squareIndexAndPosition.Index, squareHighlightDuration));
                /// WaitForSecondsRealtime suspends the coroutine execution for the given amount of seconds using scaled time.
                yield return(new WaitForSeconds(durationToWaitBetweenHighlight));
            }
        }
        /// <summary>
        /// Executes after the player clicks on a square in the recall sequence stage.
        /// The square clicked is added to the gameplay data variable.
        /// </summary>
        public IEnumerator ClickOnSquare()
        {
            // Highlight the square to indicate the successful click
            StartCoroutine(HighlightSquare(clickedSquareId, CLICK_SQUARE_HIGHLIGHT_DURATION));

            // Convert the game object to a IndexAndPosition object
            squareIndexAndPosition = GameObjectToIndexAndPosition(displayedSquares[clickedSquareId].gameObject);

            totalSquareClicks += 1;
            // Limit the number of clicks recorded to avoid "Out of memory" error
            if (totalSquareClicks < MAXIMUM_RECORDED_CLICKS)
            {
                // Add this IndexAndPosition object to the round gamedata object for recalled squares
                round.RecalledSquares.Add(squareIndexAndPosition);
            }

            isClicked = false;
            canClick  = true;

            yield return(null);
        }
Ejemplo 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);
            }
Ejemplo n.º 9
0
            public void SetUp()
            {
                // Create example clicks:
                List <TimeAndPosition> exampleClicks            = new List <TimeAndPosition>();
                TimeAndPosition        timeAndPosition_longTime = new TimeAndPosition(1.5, new Position2D(0, 0));

                exampleClicks.Add(timeAndPosition_longTime);

                // Create example balloon rounds:

                // balloonRound is an exmaple of round
                balloonRound.BalloonSize          = 60;
                balloonRound.DestinationPoint     = new Position2D(100, 200);
                balloonRound.DestinationClickTime = 0.8;
                balloonRound.Clicks            = new List <TimeAndPosition>();
                balloonRound.SuccessClickPoint = new Position2D(102, 197);

                // balloonRound_shortestPossibleDestClickTime is an exmaple of round with extreme short DestinationClickTime
                // which is smaller than 0.15s(the fastest human reaction time)
                // other fields are the same with balloonRound
                balloonRound_shortestPossibleDestClickTime.BalloonSize          = 60;
                balloonRound_shortestPossibleDestClickTime.DestinationPoint     = new Position2D(100, 200);
                balloonRound_shortestPossibleDestClickTime.DestinationClickTime = 0.1; // time smaller than 0.15 which is the fastest human reaction time
                balloonRound_shortestPossibleDestClickTime.Clicks            = new List <TimeAndPosition>();
                balloonRound_shortestPossibleDestClickTime.SuccessClickPoint = new Position2D(102, 197);

                // balloonRound_longMoveTimeInDestinationClickTime is an exmaple of round with long DestinationClickTime
                // other fields are the same with balloonRound
                balloonRound_longDestinationClickTime.BalloonSize          = 60;
                balloonRound_longDestinationClickTime.DestinationPoint     = new Position2D(100, 200);
                balloonRound_longDestinationClickTime.DestinationClickTime = 1.5; // long destination click time
                balloonRound_longDestinationClickTime.Clicks            = new List <TimeAndPosition>();
                balloonRound_longDestinationClickTime.SuccessClickPoint = new Position2D(102, 197);

                // balloonRound_longMoveTimeInClicks is an exmaple of round with long time in clicks items
                // other fields are the same with balloonRound
                balloonRound_longTimeInClicks.BalloonSize          = 60;
                balloonRound_longTimeInClicks.DestinationPoint     = new Position2D(100, 200);
                balloonRound_longTimeInClicks.DestinationClickTime = 0.8;
                balloonRound_longTimeInClicks.Clicks            = exampleClicks; // long time in clicks item
                balloonRound_longTimeInClicks.SuccessClickPoint = new Position2D(102, 197);

                // Example squares
                IndexAndPosition IndexAndPositionIndex0 = new IndexAndPosition(0, new Position2D(0, 0));
                IndexAndPosition IndexAndPositionIndex1 = new IndexAndPosition(1, new Position2D(1, 1));

                // Set data for round where Highlighted and Recalled are identical in Squares mini-game
                squareRound_sameOrder.HighlightedSquares = new List <IndexAndPosition>();
                squareRound_sameOrder.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound_sameOrder.HighlightedSquares.Add(IndexAndPositionIndex1);

                squareRound_sameOrder.RecalledSquares = new List <IndexAndPosition>();
                squareRound_sameOrder.RecalledSquares.Add(IndexAndPositionIndex0);
                squareRound_sameOrder.RecalledSquares.Add(IndexAndPositionIndex1);

                squareRound_sameOrder.RecallTime = 4f;
                squareRound_sameOrder.SquareHighlightInterval = 0.7f;
                squareRound_sameOrder.SquareHighlightInterval = 0.7f;

                // Set data for round where Highlighted and Recalled squares are in a different order in Squares mini-game
                squareRound_differentOrder.HighlightedSquares = new List <IndexAndPosition>();
                squareRound_differentOrder.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound_differentOrder.HighlightedSquares.Add(IndexAndPositionIndex1);

                squareRound_differentOrder.RecalledSquares = new List <IndexAndPosition>();
                squareRound_differentOrder.RecalledSquares.Add(IndexAndPositionIndex1);
                squareRound_differentOrder.RecalledSquares.Add(IndexAndPositionIndex0);

                squareRound_differentOrder.RecallTime = 4f;
                squareRound_differentOrder.SquareHighlightInterval = 0.7f;
                squareRound_differentOrder.SquareHighlightInterval = 0.7f;

                // Set data for round where Recalled squares has a gap value in Squares mini-game
                squareRound_gap.HighlightedSquares = new List <IndexAndPosition>();
                squareRound_gap.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound_gap.HighlightedSquares.Add(IndexAndPositionIndex1);

                squareRound_gap.RecalledSquares = new List <IndexAndPosition>();
                squareRound_gap.RecalledSquares.Add(IndexAndPositionIndex0);

                squareRound_gap.RecallTime = 4f;
                squareRound_gap.SquareHighlightInterval = 0.7f;
                squareRound_gap.SquareHighlightInterval = 0.7f;

                // Set data for round where Recalled squares has a mismatch value in Squares mini-game
                squareRound_mismatch.HighlightedSquares = new List <IndexAndPosition>();
                squareRound_mismatch.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound_mismatch.HighlightedSquares.Add(IndexAndPositionIndex1);

                squareRound_mismatch.RecalledSquares = new List <IndexAndPosition>();
                squareRound_mismatch.RecalledSquares.Add(IndexAndPositionIndex0);

                squareRound_mismatch.RecallTime = 4f;
                squareRound_mismatch.SquareHighlightInterval = 0.7f;
                squareRound_mismatch.SquareHighlightInterval = 0.7f;

                catchRound.IsIdentifiedKeyPressed = true;
                catchRound.identifiedKeyPressTime = 0.15f;
                catchRound.ThiefAppearInRound     = false;
                catchRound.PersonAppearInRound    = true;

                catchRound_longTimeInClicks.IsIdentifiedKeyPressed = true;
                catchRound_longTimeInClicks.identifiedKeyPressTime = 0.5f;
                catchRound_longTimeInClicks.ThiefAppearInRound     = true;
                catchRound_longTimeInClicks.PersonAppearInRound    = false;

                catchRound_showTimeInClicks.IsIdentifiedKeyPressed = true;
                catchRound_showTimeInClicks.identifiedKeyPressTime = 0.8f;
                catchRound_showTimeInClicks.ThiefAppearInRound     = true;
                catchRound_showTimeInClicks.PersonAppearInRound    = false;

                catchRound_showTimeInClicks.IsIdentifiedKeyPressed = true;
                catchRound_showTimeInClicks.identifiedKeyPressTime = 0.8f;
                catchRound_showTimeInClicks.ThiefAppearInRound     = true;
                catchRound_showTimeInClicks.PersonAppearInRound    = false;

                imaghtHitRound.Add(new ImageHitRound());
                imahtHitRound_longTimeInClicks.Add(new ImageHitRound());
                imageHit_showTimeInClicks.Add(new ImageHitRound());

                imaghtHitRound[0]                       = new ImageHitRound();
                imaghtHitRound[0].imageName             = "";
                imaghtHitRound[0].imageTheme            = "";
                imaghtHitRound[0].isCorrectlyIdentified = false;
                imaghtHitRound[0].isKeyPressed          = false;
                imaghtHitRound[0].isSpaceKey            = false;
                imaghtHitRound[0].keyPressTime          = 0.5f;
                imaghtHitRound[0].testTheme             = "";

                imahtHitRound_longTimeInClicks[0]                       = new ImageHitRound();
                imahtHitRound_longTimeInClicks[0].imageName             = "";
                imahtHitRound_longTimeInClicks[0].imageTheme            = "";
                imahtHitRound_longTimeInClicks[0].isCorrectlyIdentified = false;
                imahtHitRound_longTimeInClicks[0].isKeyPressed          = false;
                imahtHitRound_longTimeInClicks[0].isSpaceKey            = false;
                imahtHitRound_longTimeInClicks[0].keyPressTime          = 0.2f;
                imahtHitRound_longTimeInClicks[0].testTheme             = "";

                imageHit_showTimeInClicks[0]                       = new ImageHitRound();
                imageHit_showTimeInClicks[0].imageName             = "";
                imageHit_showTimeInClicks[0].imageTheme            = "";
                imageHit_showTimeInClicks[0].isCorrectlyIdentified = false;
                imageHit_showTimeInClicks[0].isKeyPressed          = false;
                imageHit_showTimeInClicks[0].isSpaceKey            = false;
                imageHit_showTimeInClicks[0].keyPressTime          = 0.8f;
                imageHit_showTimeInClicks[0].testTheme             = "";
            }
            public void SetUp()
            {
                // Example squares
                IndexAndPosition IndexAndPositionIndex0 = new IndexAndPosition(0, new Position2D(0, 0));
                IndexAndPosition IndexAndPositionIndex1 = new IndexAndPosition(1, new Position2D(1, 1));
                IndexAndPosition IndexAndPositionIndex2 = new IndexAndPosition(2, new Position2D(2, 2));


                // Set data for regular round without mismatch in Squares mini-game
                squareRound.HighlightedSquares = new List <IndexAndPosition>();
                squareRound.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound.HighlightedSquares.Add(IndexAndPositionIndex1);

                squareRound.RecalledSquares = new List <IndexAndPosition>();
                squareRound.RecalledSquares.Add(IndexAndPositionIndex0);
                squareRound.RecalledSquares.Add(IndexAndPositionIndex1);

                squareRound.RecallTime = 5f;
                squareRound.SquareHighlightInterval = 0.7f;
                squareRound.SquareHighlightInterval = 0.7f;

                // Set data for round with a mismatch in Squares mini-game
                squareRound_misMatch.HighlightedSquares = new List <IndexAndPosition>();
                squareRound_misMatch.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound_misMatch.HighlightedSquares.Add(IndexAndPositionIndex1);

                squareRound_misMatch.RecalledSquares = new List <IndexAndPosition>();
                squareRound_misMatch.RecalledSquares.Add(IndexAndPositionIndex0);
                squareRound_misMatch.RecalledSquares.Add(IndexAndPositionIndex2);

                squareRound_misMatch.RecallTime = 5f;
                squareRound_misMatch.SquareHighlightInterval = 0.7f;
                squareRound_misMatch.SquareHighlightInterval = 0.7f;

                // Set data for round with a gap in Squares mini-game
                squareRound_gap.HighlightedSquares = new List <IndexAndPosition>();
                squareRound_gap.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound_gap.HighlightedSquares.Add(IndexAndPositionIndex1);

                squareRound_gap.RecalledSquares = new List <IndexAndPosition>();
                squareRound_gap.RecalledSquares.Add(IndexAndPositionIndex0);

                squareRound_gap.RecallTime = 5f;
                squareRound_gap.SquareHighlightInterval = 0.7f;
                squareRound_gap.SquareHighlightInterval = 0.7f;

                // Set data for round with more correct squares in Squares mini-game
                squareRound_moreCorrectSquares.HighlightedSquares = new List <IndexAndPosition>();
                squareRound_moreCorrectSquares.RecalledSquares    = new List <IndexAndPosition>();
                for (int g = 0; g < 7; g++)
                {
                    squareRound_moreCorrectSquares.HighlightedSquares.Add(IndexAndPositionIndex0);
                    squareRound_moreCorrectSquares.RecalledSquares.Add(IndexAndPositionIndex0);
                }
                squareRound_moreCorrectSquares.RecallTime = 5f;
                squareRound_moreCorrectSquares.SquareHighlightInterval = 0.7f;
                squareRound_moreCorrectSquares.SquareHighlightInterval = 0.7f;

                // Set data for rounds with different recall times

                squareRound_3.HighlightedSquares      = new List <IndexAndPosition>();
                squareRound_3.RecalledSquares         = new List <IndexAndPosition>();
                squareRound_3.RecallTime              = 3.5f;
                squareRound_3.SquareHighlightInterval = 0.7f;
                squareRound_3.SquareHighlightInterval = 0.7f;

                squareRound_3_3.HighlightedSquares      = new List <IndexAndPosition>();
                squareRound_3_3.RecalledSquares         = new List <IndexAndPosition>();
                squareRound_3_3.RecallTime              = 3.8f;
                squareRound_3_3.SquareHighlightInterval = 0.7f;
                squareRound_3_3.SquareHighlightInterval = 0.7f;

                squareRound_3_6.HighlightedSquares      = new List <IndexAndPosition>();
                squareRound_3_6.RecalledSquares         = new List <IndexAndPosition>();
                squareRound_3_6.RecallTime              = 4.1f;
                squareRound_3_6.SquareHighlightInterval = 0.7f;
                squareRound_3_6.SquareHighlightInterval = 0.7f;

                squareRound_3_9.HighlightedSquares      = new List <IndexAndPosition>();
                squareRound_3_9.RecalledSquares         = new List <IndexAndPosition>();
                squareRound_3_9.RecallTime              = 4.4f;
                squareRound_3_9.SquareHighlightInterval = 0.7f;
                squareRound_3_9.SquareHighlightInterval = 0.7f;

                squareRound_4_2.HighlightedSquares      = new List <IndexAndPosition>();
                squareRound_4_2.RecalledSquares         = new List <IndexAndPosition>();
                squareRound_4_2.RecallTime              = 4.8f;
                squareRound_4_2.SquareHighlightInterval = 0.7f;
                squareRound_4_2.SquareHighlightInterval = 0.7f;

                for (int g = 0; g < 5; g++)
                {
                    squareRound_3.HighlightedSquares.Add(IndexAndPositionIndex0);
                    squareRound_3.RecalledSquares.Add(IndexAndPositionIndex0);

                    squareRound_3_3.HighlightedSquares.Add(IndexAndPositionIndex0);
                    squareRound_3_3.RecalledSquares.Add(IndexAndPositionIndex0);

                    squareRound_3_6.HighlightedSquares.Add(IndexAndPositionIndex0);
                    squareRound_3_6.RecalledSquares.Add(IndexAndPositionIndex0);

                    squareRound_3_9.HighlightedSquares.Add(IndexAndPositionIndex0);
                    squareRound_3_9.RecalledSquares.Add(IndexAndPositionIndex0);

                    squareRound_4_2.HighlightedSquares.Add(IndexAndPositionIndex0);
                    squareRound_4_2.RecalledSquares.Add(IndexAndPositionIndex0);

                    squareRound_6Squares.HighlightedSquares      = new List <IndexAndPosition>();
                    squareRound_6Squares.RecalledSquares         = new List <IndexAndPosition>();
                    squareRound_6Squares.RecallTime              = 3.5f;
                    squareRound_6Squares.SquareHighlightInterval = 0.7f;
                    squareRound_6Squares.SquareHighlightInterval = 0.7f;

                    squareRound_8Squares.HighlightedSquares      = new List <IndexAndPosition>();
                    squareRound_8Squares.RecalledSquares         = new List <IndexAndPosition>();
                    squareRound_8Squares.RecallTime              = 3.5f;
                    squareRound_8Squares.SquareHighlightInterval = 0.7f;
                    squareRound_8Squares.SquareHighlightInterval = 0.7f;
                }

                for (int p = 0; p < 6; p++)
                {
                    squareRound_6Squares.HighlightedSquares.Add(IndexAndPositionIndex0);
                    squareRound_6Squares.RecalledSquares.Add(IndexAndPositionIndex0);

                    squareRound_8Squares.HighlightedSquares.Add(IndexAndPositionIndex0);
                    squareRound_8Squares.RecalledSquares.Add(IndexAndPositionIndex0);
                }
                squareRound_8Squares.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound_8Squares.RecalledSquares.Add(IndexAndPositionIndex0);

                squareRound_8Squares.HighlightedSquares.Add(IndexAndPositionIndex0);
                squareRound_8Squares.RecalledSquares.Add(IndexAndPositionIndex0);
            }