示例#1
0
        //Helper functions start:
        //-----------------------------------------------------------------

        /// <summary>
        /// Initializes all state variables necessary for the Balloons mini-game.
        /// </summary>
        private void Balloon_init()
        {
            // Initialize the storage variables
            balloonsData        = new BalloonsStorage();
            balloonsData.Rounds = new List <BalloonsRound>();

            level = 0;

            // The balloon size starts at  x, y =  MAX_BALLOON_SIZE
            // The x and y values decrement by BALLOON_SIZE_DECREMENT every level
            // until it reaches a minimum value of MIN_BALLOON_SIZE
            balloonSize = MAX_BALLOON_SIZE;

            // Initialize the variables for the positions on the screen.
            destinationPoint = new Position2D(0, 0); // (world position)

            // Initialize datatype to hold the time and positions of clicks every round
            clicks = new List <TimeAndPosition>();

            // Initialize function execution booleans
            isBeingHeld       = false;
            isBalloonInCenter = false;

            // Set the balloon display timer to be a big enough number so that
            // the balloon pieces images won't be shown as the game starts
            balloonAnimationDisplayTime = 100;
        }
示例#2
0
            public IEnumerator WHEN_GetGameplayDataFunctionCalled_THEN_GamePlayDataRetured()
            {
                BalloonsStorage      balloonsData1       = Balloons.GetGameplayData();
                List <BalloonsRound> expectedRoundsData1 = new List <BalloonsRound>();

                Assert.AreEqual(expectedRoundsData1, balloonsData1.Rounds);

                balloonScript.ClickOnBalloon();
                yield return(new WaitForSeconds(0.01f));


                // After the click on balloon that is located on center point:
                BalloonsStorage      balloonsData2       = Balloons.GetGameplayData();
                List <BalloonsRound> expectedRoundsData2 = new List <BalloonsRound>();

                Assert.AreEqual(expectedRoundsData2, balloonsData2.Rounds);

                // Take 0.01s to click on the balloon that is in random position
                balloonScript.ClickOnBalloon();
                yield return(new WaitForSeconds(0.01f));

                // After the click on balloon that is located on random position:
                BalloonsStorage balloonsData3 = Balloons.GetGameplayData();

                double expectedBalloonSize            = 200;
                List <TimeAndPosition> expectedClicks = new List <TimeAndPosition>();

                Assert.AreEqual(1, balloonsData3.Rounds.Count);
                Assert.IsTrue(Math.Abs(expectedBalloonSize - balloonsData3.Rounds[0].BalloonSize) <= tolerance);
                Assert.AreEqual(expectedClicks, balloonsData3.Rounds[0].Clicks);
            }
示例#3
0
            public IEnumerator WHEN_BalloonRoundCreated_THEN_RoundIsEmpty()
            {
                balloonsData        = new BalloonsStorage();
                balloonsData.Rounds = new List <BalloonsRound>();
                int expectedSizeOfList = 0;

                yield return(null);

                Assert.IsTrue(expectedSizeOfList == balloonsData.Rounds.Count);
            }
        /// <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();
            }
        }
示例#5
0
            public IEnumerator WHEN_BalloonRoundAdded1Round_THEN_BalloonRoundSizeIs1()
            {
                balloonsData        = new BalloonsStorage();
                balloonsData.Rounds = new List <BalloonsRound>();

                round = new BalloonsRound();
                balloonsData.Rounds.Add(round);

                int expectedSizeOfList = 1;

                yield return(null);

                Assert.IsTrue(expectedSizeOfList == balloonsData.Rounds.Count);
            }
示例#6
0
            public IEnumerator WHEN_BalloonRoundAdded1Round_THEN_BalloonRoundGetterReturnsCorrectValues()
            {
                balloonsData        = new BalloonsStorage();
                balloonsData.Rounds = new List <BalloonsRound>();

                round = new BalloonsRound();

                round.BalloonSize = 180;
                double expectedBalloonSize = 180;

                round.DestinationClickTime = 1.5;
                double expectedDestinationClickTime = 1.5;

                round.DestinationPoint = new Position2D(0, 0);
                Position2D expectedDestinationPoint = new Position2D(0, 0);

                round.SuccessClickPoint = new Position2D(-200, 67);
                Position2D expectedSuccessClickPoint = new Position2D(-200, 67);

                TimeAndPosition testItem1 = new TimeAndPosition(0.5, new Position2D(10, 20));
                TimeAndPosition testItem2 = new TimeAndPosition(1.5, new Position2D(0.1, -40));

                round.Clicks = new List <TimeAndPosition>();
                round.Clicks.Add(testItem1);
                round.Clicks.Add(testItem2);

                balloonsData.Rounds.Add(round);
                BalloonsRound actualCirclesRound = balloonsData.Rounds[0];

                yield return(null);

                Assert.IsTrue(expectedBalloonSize == actualCirclesRound.BalloonSize);
                Assert.IsTrue(expectedDestinationClickTime == actualCirclesRound.DestinationClickTime);
                Assert.IsTrue(Math.Abs(expectedDestinationPoint.X - actualCirclesRound.DestinationPoint.X) <= tolerance &&
                              Math.Abs(expectedDestinationPoint.Y - actualCirclesRound.DestinationPoint.Y) <= tolerance);
                Assert.IsTrue(Math.Abs(expectedSuccessClickPoint.X - actualCirclesRound.SuccessClickPoint.X) <= tolerance &&
                              Math.Abs(expectedSuccessClickPoint.Y - actualCirclesRound.SuccessClickPoint.Y) <= tolerance);
                Assert.IsTrue(2 == actualCirclesRound.Clicks.Count);
                Assert.IsTrue(Math.Abs(testItem1.Time - actualCirclesRound.Clicks[0].Time) <= tolerance &&
                              Math.Abs(testItem1.Position.X - actualCirclesRound.Clicks[0].Position.X) <= tolerance &&
                              Math.Abs(testItem1.Position.Y - actualCirclesRound.Clicks[0].Position.Y) <= tolerance);
                Assert.IsTrue(Math.Abs(testItem2.Time - actualCirclesRound.Clicks[1].Time) <= tolerance &&
                              Math.Abs(testItem2.Position.X - actualCirclesRound.Clicks[1].Position.X) <= tolerance &&
                              Math.Abs(testItem2.Position.Y - actualCirclesRound.Clicks[1].Position.Y) <= tolerance);
            }