Ejemplo n.º 1
0
 public static void Restore(EnemyShip item)
 {
     if (item.GetType() == typeof(RedEnemyShip))
     {
         shipsPool[1].Enqueue(item);
     }
     else
     {
         shipsPool[0].Enqueue(item);
     }
 }
Ejemplo n.º 2
0
        public static void Update()
        {
            //ships spawn
            shipSpawnCounter -= Game.DeltaTime;
            if (shipSpawnCounter <= 0)
            {
                shipSpawnCounter = RandomGenerator.GetRandom(3, 5);

                int       choice  = RandomGenerator.GetRandom(0, 100);
                EnemyShip newShip = null;
                if (choice < 60)
                {
                    choice = 0;
                }
                else
                {
                    choice = 1;
                }

                newShip = shipsPool[choice].Dequeue();

                SetRandomPosition(newShip);
                newShip.IsActive = true;
            }

            //power up spawn
            powerUpSpawnCounter -= Game.DeltaTime;

            if (powerUpSpawnCounter <= 0)
            {
                powerUpSpawnCounter = RandomGenerator.GetRandom(8, 15);

                PowerUp p = GetRandomPowerUp();
                if (p != null)
                {
                    SetRandomPosition(p);
                    p.IsActive = true;
                }
            }
        }