//coroutine to spawn all obstacles in a wave
    //to specify which obstacles from which wave they are going to spawn
    private IEnumerator SpawnAllObstaclesInWave(ObstacleWave waveConfig)
    {
        //loop to spawn multiple obstacles in a wave
        for (int obstacleCount = 1; obstacleCount <= waveConfig.GetNumberOfObstacles(); obstacleCount++)
        {
            var obstacle = Instantiate(waveConfig.GetObstaclePrefab(), waveConfig.GetWayPoints()[0].transform.position, Quaternion.identity);

            obstacle.GetComponent <ObstaclePathing>().SetWaveConfig(waveConfig);

            yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns()));
        }
    }
    private IEnumerator SpawnAllEnemiesInWave(ObstacleWave waveToSpawn)
    {
        for (int enemyCount = 1; enemyCount <= waveToSpawn.GetNumberOfEnemies(); enemyCount++)
        {
            var newEnemy = Instantiate(
                waveToSpawn.GetEnemyPrefab(),
                waveToSpawn.GetWaypoints()[0].transform.position,
                Quaternion.identity);

            newEnemy.GetComponent <EnemyPathing>().SetObstacleWave(waveToSpawn);

            yield return(new WaitForSeconds(waveToSpawn.GetTimeBetweenSpawns()));
        }
    }