Example #1
0
    IEnumerator SpawnAllWaves()
    {
        for (int waveIndex = startingWave; waveIndex < waveConfigs.Count; waveIndex++)
        {
            WaveConfig currentWave = waveConfigs[waveIndex];
            if (FindObjectOfType <Player>() == null || FindObjectOfType <Player>().destroyed)
            {
                StopAllCoroutines();
                Destroy(gameObject);
            }
            if (currentWave.GetSkipDelay())
            {
                StartCoroutine(SpawnWave(currentWave));
                yield return(null);
            }
            else
            {
                yield return(StartCoroutine(SpawnWave(currentWave)));

                yield return(StartCoroutine(Timer.Delay(currentWave.GetDelay() * currentWave.GetMovespeed())));
            }
        }
    }
Example #2
0
    IEnumerator Move()
    {
        if (waypointIndex < waypoints.Count)
        {
            Waypoint waypoint          = waypoints[waypointIndex].GetComponent <Waypoint>();
            Vector3  targetPos         = waypoints[waypointIndex].transform.position;
            float    movementThisFrame = waveConfig.GetMovespeed() * waypoint.GetSpeedMod() * Time.deltaTime;
            transform.position = Vector2.MoveTowards(
                transform.position, targetPos, movementThisFrame);
            if (transform.position == targetPos)
            {
                waiting = true;
                yield return(StartCoroutine(Timer.Delay(waypoint.GetWait())));

                waiting = false;
                waypointIndex++;
            }
        }
        else
        {
            Destroy(gameObject);
            yield return(null);
        }
    }