IEnumerator PlayLevelSequence(EnemySequence levelSequence) { for (int nodeNumber = 0; nodeNumber < levelSequence.nodeList.Length; nodeNumber++) { EnemySequenceNode toSpawn = levelSequence.nodeList[nodeNumber]; yield return(new WaitForSeconds(toSpawn.delayTillSpawn)); GameObject newEnemy = null; switch (toSpawn.enemyType) { case EnemyType.spiral: newEnemy = SpawnAnEnemy(toSpawn.allowableSpawnArea[UnityEngine.Random.Range(0, toSpawn.allowableSpawnArea.Count)], spiralEnemyPrefab); break; default: case EnemyType.basic: newEnemy = SpawnAnEnemy(toSpawn.allowableSpawnArea[UnityEngine.Random.Range(0, toSpawn.allowableSpawnArea.Count)], basicEnemyPrefab); break; } newEnemy.GetComponent <BaseEnemyBehaviour>().InitializeEnemy(player.position, this); newEnemy.GetComponent <BaseEnemyBehaviour>().StartEnemyBehaviour(); AddEnemyToCurrentList(newEnemy); } yield return(null); }
// Start is called before the first frame update void Start() { EnemySequence firstSequence = LoadEnemySequence(levelDataList[0]); StartCoroutine(PlayLevelSequence(firstSequence)); }