Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        obstaclesWaypoints = waveConfig.GetWayPoints();


        transform.position = obstaclesWaypoints[waypointIndex].transform.position;
    }
    [SerializeField][Range(0, 1)] float playerPointsGainedRangeVolume = 0.70f;  //[Range(0, 1)] to set the voloume between 0 and 100%

    // Start is called before the first frame update
    void Start()
    {
        //get the List waypoints from WaveConfig
        waypoints = waveConfig.GetWayPoints();

        //set the start position of obstacle to the first waypoint position
        transform.position = waypoints[waypointElement].transform.position;
    }
    //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()));
        }
    }