示例#1
0
    private IEnumerator SpawnAllBEATzInWave(WaveConfiguration waveConfig)
    {
        // For each number of BEATz that we will spawn in the scene, we will increment the BEAT count by 1.
        for (int BEATCount = 0; BEATCount < waveConfig.GetSpawnNumber(); BEATCount++)
        {
            // Local Variables
            // 1.) The BEAT that we will be spawning
            var BEAT = waveConfig.GetBEATPrefab();
            // 2.) The BEAT position on spawn
            var BEATPosition = waveConfig.GetWaypoints()[0].transform.position;
            // 3.) Spawn BEAT
            var newBEAT = Instantiate(BEAT, BEATPosition, Quaternion.identity);
            // 4.) The starting time of a spawn pattern.
            int startingSpawnDuration = 0;
            // 5.) The duration time of spawning BEATz
            float endingSpawnDuration = waveConfig.GetSpawnDuration();

            SpawnBEATz(waveConfig, BEAT, newBEAT);

            // Wait before spawning another BEAT.
            yield return(new WaitForSeconds(waveConfig.GetSpawnRate()));

            BEATCount = SpawnAnotherBEAT(waveConfig, BEATCount, startingSpawnDuration, endingSpawnDuration);

            // If delay is ON, then wait a second.
            if (waveConfig.GetDelay() && endingSpawnDuration == startingSpawnDuration)
            {
                yield return(new WaitForSeconds(waveConfig.GetDelayInterval()));
            }
        }
    }
示例#2
0
    private int SpawnAnotherBEAT(WaveConfiguration waveConfig, int BEATCount, int startingSpawnDuration, float endingSpawnDuration)
    {
        // If BEAT count is greater than the spawn number and the endingSpawnDuration is less than the starting spawn duration..
        if (BEATCount > waveConfig.GetSpawnNumber() && endingSpawnDuration < startingSpawnDuration)
        {
            // Decrement the BEAT Count.
            BEATCount--;
        }

        return(BEATCount);
    }