Exemple #1
0
 /// <summary>
 /// This method sets a formula that must be evaluated before deciding whether the player can progress to the next level. Added by Isaac.
 /// </summary>
 public void ControlLevels()
 {
     if (EnemiesToBeRemoved.Count >= GameLevel.GetFormula())
     {
         GameLevel.IncreaseLevel();   // IA - move the next level if enough enemies have been destroyed
         Food.IncreaseMineralValue(); // IA - Make food more expensive
         Food.IncreaseEnergyValue();  // IA - Make the food conversion to energy less significant.
         EnemiesToBeRemoved.Clear();  // IA - Reset the count of enemies destroyed at each level.
         GetWorld().PutMinerals();    //jeremy - for every new level, new minerals added to game
     }
 }
Exemple #2
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());
        }
Exemple #3
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());
        }
Exemple #4
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());
        }
Exemple #5
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();
        }