private IEnumerator SpawnEnemy() { float spawnDelay = Random.Range(minSpawnDelay, maxSpawnDelay); yield return(new WaitForSeconds(spawnDelay)); Transform spawnPoint = spawnPoints[spawnIndex]; spawnIndex = (spawnIndex + 1) % spawnPoints.Length; Enemy enemy = Instantiate(enemyPrefab, spawnPoint.position, Quaternion.identity); enemy.AddDeathListener(RespawnEnemy); }
private IEnumerator SpawnWave() { WaveCount++; enemiesRemaining += 4 * spawnCount; for (int i = 0; i < spawnCount; i++) { foreach (Transform spawnPoint in spawnPoints) { Enemy enemy = Instantiate(enemyPrefab, spawnPoint.position, Quaternion.identity); enemy.AddDeathListener(RemoveEnemy); } yield return(spawnInstruction); } UpdateWave(); }