示例#1
0
 void Awake()
 {
     spawnPoint    = enemySpawnPoint.GetComponent <WytriamSTD.Spawn>();
     index         = 0;
     enemiesInWave = enemiesPerWave[index];
     if (enemiesPerWave.Length != waves.Length)
     {
         Debug.Log("Waves not properly set up - enemiesPerWave and waves length not equal");
     }
 }
示例#2
0
 // Co-routine to handle spawning waves
 IEnumerator spawnWaves()
 {
     isSpawning = true;
     while (index < waves.Length)
     {
         if (spawnCount % enemiesInWave == 0 && index != 0)
         {
             GetComponent <WytriamSTD.Scene_Manager>().announce("Wave " + (index + 1) + " of " + waves.Length);
         }
         currentPrefab = waves[index];
         spawnEnemy();
         if (spawnCount % enemiesInWave == 0)
         {
             index++;
             if (alternateWaypoints.Length != 0)
             {
                 firstWaypoint = alternateWaypoints[index % alternateWaypoints.Length];
             }
             if (alternateSpawns.Length != 0)
             {
                 spawnPoint = alternateSpawns[index % alternateSpawns.Length].GetComponent <WytriamSTD.Spawn>();
             }
             spawnCount    = 0;
             enemiesInWave = enemiesPerWave[index % enemiesPerWave.Length];
         }
         if (spawnCount % enemiesInWave == 0 && index != 0)
         {
             yield return(new WaitForSeconds(timeBetweenWaves));
         }
         else
         {
             yield return(new WaitForSeconds(1 / enemiesPerSecond));
         }
     }
     isSpawning = false;
     // Stop spawning waves if we're out of enemies
     if (index > waves.Length)
     {
         StopCoroutine("spawnWaves");
     }
 }
示例#3
0
 // Use this for initialization
 void Start()
 {
     spawnScript = GetComponent <WytriamSTD.Spawn>();
     sound       = GetComponent <AudioSource>();
 }