Example #1
0
    //courintines

    //say which wave we need to spawn obstacles from
    private IEnumerator SpawnAllObstaclesInWave(WaveConfigObstc waveToSpawn)
    {
        // to start get the number of obstacles,to come after each other in wave
        for (int obstacleCount = 1; obstacleCount <= waveToSpawn.GetNumberOfObstacles(); obstacleCount++)
        {
            //spawn  obstacle from waveConfigObstc to pos by the waypoint of the wave
            //create prefab whic  from wave config add pos of 1 waypoint of the wave spawn
            var newObstacle = Instantiate(
                waveToSpawn.GetObstaclePrefab(),
                waveToSpawn.GetWaypoints()[0].transform.position,
                Quaternion.identity);

            //wave selcted and the obstcale that it has
            newObstacle.GetComponent <EnemyPathing>().SetWaveConfig(waveToSpawn);


            //wait between each spawns  of obstacles
            yield return(new WaitForSeconds(waveToSpawn.GetTimeBetweenSpawns()));
        }
    }
 // do the waveconfig to set
 public void SetWaveConfig(WaveConfigObstc waveConSet)
 {
     waveConfig = waveConSet;
 }