void DropSun()
 {
     if ((int)Program.GetGameClock().ElapsedMilliseconds > currentClockForSun + timeBetweenSun)
     {
         ObjectSpawner.SpawnSun(xPosition, yPosition);
         currentClockForSun = (int)Program.GetGameClock().ElapsedMilliseconds;
     }
 }
        void PlacePlant()
        {
            if (!Utility.GetKeyState(ConsoleKey.Spacebar))
            {
                dropping = false;
            }
            else if (Utility.GetKeyState(ConsoleKey.Spacebar) && !dropping)
            {
                switch (currentPlant)
                {
                case (int)PlantTypes.SunFlower:
                    currentPlantsPrice = 50;
                    break;

                case (int)PlantTypes.PeaShooter:
                    currentPlantsPrice = 100;
                    break;

                case (int)PlantTypes.CherryBomb:
                    currentPlantsPrice = 150;
                    break;

                case (int)PlantTypes.WallNut:
                    currentPlantsPrice = 50;
                    break;

                case (int)PlantTypes.PotatoMine:
                    currentPlantsPrice = 25;
                    break;

                case (int)PlantTypes.GatlingPea:
                    currentPlantsPrice = 250;
                    break;

                case (int)PlantTypes.Jalapeno:
                    currentPlantsPrice = 125;
                    break;
                }
                if (sunPoints >= currentPlantsPrice)
                {
                    for (int i = 0; i < GameBoard.GetGrids().Length; i++)
                    {
                        if (GameBoard.GetGrids()[i])
                        {
                            if ((int)xPosition == GameBoard.GetGridPosX()[i] && (int)yPosition == GameBoard.GetGridPosY()[i])
                            {
                                return;
                            }
                        }
                    }
                    ObjectSpawner.SpawnPlant(xPosition, yPosition, currentPlant);
                    dropping = true;
                }
            }
        }
Beispiel #3
0
 void Shoot()
 {
     if ((int)Program.GetGameClock().ElapsedMilliseconds > currentClockForShot + timeBetweenShots)
     {
         if (GameBoard.GetRowInUseByZombie()[inRow])
         {
             ObjectSpawner.SpawnProjectile(xPosition, yPosition);
         }
         currentClockForShot = (int)Program.GetGameClock().ElapsedMilliseconds;
     }
 }
 public static void InitGame()
 {
     Program.InitGameClock(new Stopwatch());
     ObjectPooler.InitPooler();
     ObjectSpawner.InitSpawner();
     Program.InitRandomNumber(new Random());
     Program.InitPlayer(new PlayerCursor());
     WaveController.InitWaveCont();
     //Loop.SpriteTestor();
     GameBoard.InitGameBoard();
 }
Beispiel #5
0
 public static void Update()
 {
     if (waveInProgress)
     {
         if ((int)Program.GetGameClock().ElapsedMilliseconds > currentClockForSpawn + timeBetweenSpawns)
         {
             ObjectSpawner.SpawnZombie();
             currentClockForSpawn = (int)Program.GetGameClock().ElapsedMilliseconds;
         }
     }
     else
     {
         if ((int)Program.GetGameClock().ElapsedMilliseconds > timeBeforeWave)
         {
             StartWave();
         }
     }
 }