private IEnumerator SpawnAllObjectsInWave(WaveConfig waveToSpawn) { for (int objectCount = 1; objectCount <= waveToSpawn.GetNumberOfObstacles(); objectCount++) { var newEnemy = Instantiate( waveToSpawn.GetEnemyPrefab(), waveToSpawn.GetWaypoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <ObstaclePathing>().SetWaveConfig(waveToSpawn); yield return(new WaitForSeconds(waveToSpawn.GetTimeBetweenSpawns())); } }
private IEnumerator SpawnAllObstacles(WaveConfig waveConfig) { //spawn an emeny until obstacleCount is equal to getNumberOfObstacles() for (int obstacleCount = 0; obstacleCount < waveConfig.GetNumberOfObstacles(); obstacleCount++) { //spawn the obstacles from waveConfig //at the position specifies by the waveConfig waypoints var newObstacle = Instantiate( waveConfig.GetObstaclePrefab(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity); //the wave will be selected from here and the obstacle applied to it newObstacle.GetComponent <ObstaclePathing>().SetWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns())); } }
private IEnumerator SpawnAllObstaclesInWave(WaveConfig waveToSpawn) { for (int enemyCount = 0; enemyCount < waveToSpawn.GetNumberOfObstacles(); enemyCount++) { //spawn the enemyPrefab from waveToSpawn //at the position specifided waveToSpawn waypoints var newEnemy = Instantiate( waveToSpawn.GetObstaclePrefab(), waveToSpawn.GetWaypoints()[0].transform.position, Quaternion.identity); //select the wave and apply the enemy to it newEnemy.GetComponent <Pathing>().SetWaveConfig(waveToSpawn); //wait spawnTime yield return(new WaitForSeconds(waveToSpawn.GetTimeBetweenSpawns())); } }