Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (spawnDelayCountdown <= 0)
     {
         spawnDelayCountdown = 3f;
         if (wave.enemysAlive < maxEnemysAllowed)
         {
             //if the amount of enemy to spawn is greater than the max enemys allowed, then spawn the max enemys that is allowed and substract until its less then maxEnemysAllowed
             if (wave.CanSpawnEnemy())
             {
                 if (wave.amountToSpawn > maxEnemysAllowed)
                 {
                     wave.amountToSpawn -= maxEnemysAllowed;
                     StartCoroutine(SpawnWave(maxEnemysAllowed));
                 }
                 else
                 {
                     int amount = wave.amountToSpawn;
                     wave.amountToSpawn = (wave.enemysAlive % wave.amountToSpawn);
                     amount             = amount - wave.amountToSpawn;
                     StartCoroutine(SpawnWave(amount));
                 }
             }
         }
         if (wave.IsFinished())
         {
             wave.NewWave();
         }
     }
     else
     {
         spawnDelayCountdown -= Time.deltaTime;
     }
 }