Example #1
0
        public void PrintLevelTest()
        {
            GameLevel.SetLevel(10);             // Level 10

            // The PrintLevel() method should return the level "10" as a string.
            StringAssert.AreEqualIgnoringCase("10", GameLevel.PrintLevel());
        }
Example #2
0
        public void IncreaseMineralValueTest()
        {
            // Reminder => The mineral value should be increased using the following formula: CurrentMineralValue + GameLevel / 1.5
            // ...with "GameLevel" referring to the current game level the player is in.

            Food.ResetMineralValue();           // Set the mineral value to the default value of 1.
            GameLevel.SetLevel(15);             // Set the game to Level 15;
            Food.IncreaseMineralValue();        // Use the formula above

            // The new mineral value should be: 1 + 15 / 1.5 = 11.00
            // The GetMineralValue() method returns a double rounded off to 2 decimals.
            Assert.AreEqual(11.00, Food.GetMineralValue());

            // Reuse the obtained mineral value to increase again after changing the game level as well.
            GameLevel.SetLevel(9);             // Level 9, now.
            Food.IncreaseMineralValue();

            // The new mineral value should be: 11 + 9 / 1.5 = 17.00
            Assert.AreEqual(17.00, Food.GetMineralValue());

            // The mineral value can no longer be increased once it is greater than 15.
            GameLevel.SetLevel(30);             // Level 30, now.
            Food.IncreaseMineralValue();

            // The new mineral value should be: 17 + 30 / 1.5 = 37
            Assert.IsTrue(Food.GetMineralValue() == 17.00);             // The value should be frozen to its previous state.
        }
Example #3
0
        public void ResetLevelTest()
        {
            GameLevel.SetLevel(10);
            GameLevel.ResetLevel();             // Set the level back to 1.

            Assert.AreEqual(1, GameLevel.GetLevel());
        }
Example #4
0
        public void GetAndSetLevelTest()
        {
            GameLevel.SetLevel(2);
            Assert.AreEqual(2, GameLevel.GetLevel());

            GameLevel.SetLevel(25);
            Assert.AreEqual(25, GameLevel.GetLevel());
        }
Example #5
0
        public void IncreaseLevelTest()
        {
            GameLevel.SetLevel(1);
            GameLevel.IncreaseLevel();             // Increase the level by one.

            Assert.AreEqual(2, GameLevel.GetLevel());

            GameLevel.SetLevel(50);
            GameLevel.IncreaseLevel();
            GameLevel.IncreaseLevel();
            GameLevel.IncreaseLevel();             // Call it three times to get 53.

            Assert.AreEqual(53, GameLevel.GetLevel());
        }
Example #6
0
        public void GetFormulaTest()
        {
            // Reminder: The GameLevel class' formula = (LevelNo * 5) + 1 + (LevelNo * LevelNo)
            // ...with "LevelNo" referring to the player's current game level.

            GameLevel.SetLevel(3);

            // (3 * 5) + 1 + (3 * 3) = 15 + 1 + 9 = 25
            Assert.AreEqual(25, GameLevel.GetFormula());

            GameLevel.SetLevel(14);

            // (14 * 5) + 1 + (14 * 14) = 70 + 1 + 196 = 267
            Assert.AreEqual(267, GameLevel.GetFormula());
        }
Example #7
0
        public void IncreaseEnergyValueTest()
        {
            // Reminder => The formula to calculate the energy value is: CurrentEnergyValue + CurrentMineralValue - CurrentGameLevel;

            Food.ResetEnergyValue();           // Set the energy value to the default value of 2.
            Food.ResetMineralValue();          // Default is 1.
            GameLevel.SetLevel(1);             // Level 1.

            // The energy value should be: 2 + 1 - 1 = 2
            // The GetEnergyValue() method returns a double rounded off to 2 decimals.
            Assert.AreEqual(2.00, Food.GetEnergyValue());

            // Increase the game level and test again.
            GameLevel.IncreaseLevel();             // Level 2, now.

            // A level increase changes the mineral value as well (see the IncreaseMineralValueTest() above)
            // The new energy value should be: 2 + 2 - 2 = 1;
            Assert.AreEqual(2.00, Food.GetEnergyValue());
        }
Example #8
0
        public void EndGame(string status)
        {
            SwinGame.PlayMusic(GameResources.GameMusic("main_menu_music"));
            bool proceed = false;

            // IA - Reset minerals, game levels, food purchased and energy levels.
            Food.SetBalance(0);
            Food.ResetFoodPurchased();
            Food.ResetMineralValue();
            Food.ResetEnergyValue();
            MetaHandler.ResetEnergyLevels();
            MetaHandler.SetFoodMessage("Hit Space to enter amount.");
            MetaHandler.ResetAmmunitionMessage1();
            MetaHandler.ResetAmmunitionMessage2();
            GameLevel.SetLevel(1);
            EnemiesToBeRemoved.Clear();
            GetPlayer().DestroyWeapon();

            // IA - Clear the input field from the Food Exchange Center
            if (Input.ReadingText())
            {
                Input.EndReadingText();
            }


            GetPlayer().Inventory.ClearInventory();
            if (_twoplayer == true)
            {
                _player2.Inventory.ClearInventory();
                _player2.DestroyWeapon();
            }


            while (!proceed)
            {
                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawBitmap(GameResources.GameImage(status), 0, 0);

                SwinGame.ProcessEvents();

                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    if (_twoplayer == true)
                    {
                        _player2.Location.X = 45;
                        _player2.Location.Y = 30;
                    }
                    proceed     = true;
                    initdone    = false;
                    initdone2   = false;
                    initPlayer2 = false;
                    _twoplayer  = false;
                    firstGame   = false;
                }

                SwinGame.RefreshScreen(60);
            }
            SwinGame.ClearScreen(Color.White);
            _gameStates.Push(GameState.ViewingMainMenu);
            ControlGameState();
        }