示例#1
0
    public static void SpawnEnemies()
    {
        // Spawn dummy Enemy first round
        if (currentRound.round == 0 && Enemy.allEnemies.Count == 0)
        {
            new Enemy(EnemyType.Dummy);
        }

        var rnd = new Random();

        // Spawn new enemy
        if (Raylib.GetTime() > currentRound.timeTillNextSpawn && Enemy.allEnemies.Count < 10)
        {
            if (RoundManager.EnemiesLeft() > 0)
            {
                bool enemySpawned = false;

                while (!enemySpawned)
                {
                    int enemyToSpawn = rnd.Next(0, 3);

                    if (enemyToSpawn == 0 && currentRound.enemies.easy > 0)
                    {
                        enemySpawned = true;
                        new Enemy(EnemyType.Easy);
                        RoundManager.currentRound.enemies.easy--;
                    }
                    else if (enemyToSpawn == 1 && currentRound.enemies.hard > 0)
                    {
                        enemySpawned = true;
                        new Enemy(EnemyType.Hard);
                        currentRound.enemies.hard--;
                    }
                    else if (enemyToSpawn == 2 && currentRound.enemies.kamikaze > 0)
                    {
                        enemySpawned = true;
                        new Enemy(EnemyType.Kamikaze);
                        currentRound.enemies.kamikaze--;
                    }
                }
            }
            else if (currentRound.enemies.boss > 0)
            {
                bossAlive = true;
                new BossSun();
                RoundManager.currentRound.enemies.boss--;
            }
            int extraTime = 0;
            if (EnemiesLeft() == 0 && currentRound.enemies.boss > 0)
            {
                extraTime = 5;
            }
            currentRound.timeTillNextSpawn = (float)Raylib.GetTime() + currentRound.spawnRate + extraTime;
        }
    }