Пример #1
0
        private static void levelSpawner()
        {
            int randEnemySpawn = rand.Next(1, 3);

            //Level 1
            if (!PlayerShip.Instance.IsDead && EntityManager.Count < 200)
            {
                if (rand.Next((int)inverseSpawnChance) == 0 && PlayerShip.Instance.level != 4)
                {
                    EntityManager.Add(Enemy.CreateSeeker(GetSpawnPosition()));
                }
                else if (rand.Next((int)inverseSpawnChance) == 10 && PlayerShip.Instance.level == 2)
                {
                    //Level 2
                    EntityManager.Add(Enemy.CreateStraightLineEnemy(GetSpawnPosition()));
                }

                else if (rand.Next((int)inverseSpawnChance) == 10 && PlayerShip.Instance.level == 3)
                {
                    Console.WriteLine("Random Enemy: " + randEnemySpawn);
                    //Level 3
                    switch (randEnemySpawn)
                    {
                    case 1:
                        EntityManager.Add(Enemy.CreateStraightLineEnemy(GetSpawnPosition()));
                        Console.WriteLine("Random Enemy: " + randEnemySpawn);
                        break;

                    case 2:
                        EntityManager.Add(Enemy.CreateStraightLineEnemyLeft(GetSpawnPositionRightSide()));
                        EntityManager.Add(Enemy.CreateStraightLineEnemyLeft(GetSpawnPositionRightSide()));
                        break;
                    }
                }
                //Final Level
                else if (rand.Next((int)inverseSpawnChance) == 10 && PlayerShip.Instance.level == 4)
                {
                    if (PlayerShip.Instance.bossSpawned == false)
                    {
                        EntityManager.Add(Enemy.CreateBoss(bossSpawnPos));
                    }

                    switch (randEnemySpawn)
                    {
                    case 1:
                        EntityManager.Add(Enemy.CreateStraightLineEnemy(GetSpawnPosition()));
                        break;

                    case 2:
                        EntityManager.Add(Enemy.CreateStraightLineEnemyLeft(GetSpawnPositionRightSide()));
                        break;

                    case 3:
                        EntityManager.Add(Enemy.CreateStraightLineEnemyRight(GetSpawnPositionLeftSide()));
                        break;
                    }
                }
            }
            // slowly increase the spawn rate as time progresses
            if (inverseSpawnChance > 20)
            {
                inverseSpawnChance -= 0.01f;
            }
        }