コード例 #1
0
ファイル: SpawnManager.cs プロジェクト: Patch095/SpaceShooter
        public static void EnemiesSpawn()
        {
            spawnTimer -= Game.Window.deltaTime;
            fireTimer  -= Game.Window.deltaTime;

            if (spawnTimer <= 0)
            {
                int randomType = RandomGenerator.GetRandom(0, 11);
                int spanwType;
                if (randomType <= 1)
                {
                    spanwType = 0;//Bonus
                }
                else if (randomType > 1 && randomType < 4)
                {
                    spanwType = 1;//Bot
                }
                else if (randomType >= 4 && randomType < 6)
                {
                    spanwType = 2;//Red
                }
                else
                {
                    spanwType = 3;//Standard
                }
                if (enemies[spanwType].Count > 0)
                {
                    EnemyShip enemy = enemies[spanwType].Dequeue();

                    if (spanwType == 1)
                    {
                        enemy.OnSpawn(new Vector2(Game.Window.Width + POS_X, Game.Window.Height - 30));
                        spawnTimer = MAX_TIMER / 3;
                    }
                    else
                    {
                        enemy.OnSpawn(new Vector2(Game.Window.Width + POS_X, RandomGenerator.GetRandom(enemy.Height / 2, Game.Window.Height - enemy.Height / 2)));
                        if (spanwType == 0)
                        {
                            ((PowerUp)enemy).PowerValue = RandomGenerator.GetRandom(0, 3);
                        }
                        spawnTimer = MAX_TIMER;
                    }
                }
            }
            if (fireTimer <= 0)
            {
                FireShoot();
                fireTimer = FIRE_TIMER;
            }
        }
コード例 #2
0
ファイル: SpawnManager.cs プロジェクト: Patch095/SpaceShooter
 static public void Restore(EnemyShip enemy)
 {
     enemies[(int)enemy.Type].Enqueue(enemy);
 }