private void Spawner_OnFinished(SpawnInterval spawn)
 {
     _spawnersFinished++;
     if (_spawnersFinished == _spawnerAmount)
     {
         OnAllSpawnersFinished?.Invoke(this);
     }
     OnSpawnerFinished?.Invoke(this, spawn);
 }
        private IEnumerator HandleSpawn(SpawnInterval spawn)
        {
            yield return(new WaitForSeconds(spawn.StartTime));

            ISpawner spawner = Instantiate(SpawnerPrefab).GetComponent <ISpawner>();

            float delay = spawn.Length / spawn.Amount;

            spawner.OnFinished += () => Spawner_OnFinished(spawn);
            spawner.OnSpawn    += Spawner_OnSpawn;

            spawner.Spawn(spawn.Amount, delay, GetPrefab(spawn.EnemyIdentifier));
        }
Beispiel #3
0
        private float GenerateParallelWaves(WaveTimeline timeline, float startTime, int wave, float credits, ref int offset)
        {
            float frequency = GetSpawnFrequency(wave);

            int waves = GetParallelAmount(wave);

            for (int i = 0; i < waves; i++)
            {
                float waveFrequency = frequency * (1 + RandomRange(FrequencyVariance.x, FrequencyVariance.y));
                float waveCredits   = credits * (1 + RandomRange(CreditsVariance.x, CreditsVariance.y));

                IWaveGenerator gen      = new WaveGenerator(startTime, wave, Seed + offset++, waveCredits / waves, waveFrequency / waves, MaxSpawnFrequency / waves, MinSpawnFrequency / waves);
                SpawnInterval  interval = gen.Generate();
                timeline.AddSpawn(interval);
            }
            return(timeline.EndTime + RandomRange(TimeVariance.x, TimeVariance.y));
        }