示例#1
0
    public void SpawnNextEnemy(RobotWave wave)
    {
        List <Robot> robots = wave.GetRobots();
        int          rand   = Random.Range(0, robots.Count);
        Robot        robot  = robots[rand];
        string       tag    = robot.GetPrefab().name;

        if (robotPool.ContainsKey(tag))
        {
            GameObject robotObj = robotPool[tag].Dequeue();
            robotPool[tag].Enqueue(robotObj);
            Enemy enemy = robotObj.GetComponent <Enemy>();
            enemiesOnTheField.Add(enemy);
            enemy.Init();
            robotObj.SetActive(true);
            wave.SetAmountUsedInRobot(rand, robot.GetUsed() + 1);
        }
    }
示例#2
0
 public IEnumerator Spawner()
 {
     //restartButtonHolder.SetActive(true);
     while (currentWave < waves.Count)
     {
         RobotWave wave  = waves[currentWave];
         int       count = wave.GetRobots().Count;
         if (count > 0)
         {
             SpawnNextEnemy(wave);
         }
         else
         {
             StartCoroutine(NextWave());
             break;
         }
         yield return(new WaitForSeconds(spawnDelay));
     }
 }