public IEnumerator StartWave() { countDown = warmupTime; WarmupText.warmupGui = countDown; WarmupTextShadow.warmupGui = countDown; killedNpcs = 0; NpcsToSpawn = 0; if (waveNumber <= waves.Length) { if (waveNumber < waves.Length) { waveNumber++; } else { //start again from first wave if last wave was completed lastWave = true; waveNumber = 1; } } else { waveNumber = 1; } WaveText.waveGui = waveNumber; WaveTextShadow.waveGui = waveNumber; tempColor.a = 1.0f; tempColor2.a = 1.0f; WarmupText.waveBegins = false; WarmupTextShadow.waveBegins = false; if (waveNumber > 1 || lastWave) { startTime = Time.time; WarmupText.waveComplete = true; WarmupTextShadow.waveComplete = true; if (waveEndFx && !fxPlayed2) { asource.PlayOneShot(waveEndFx, 1.0f); FPSPlayerComponent.StartCoroutine(FPSPlayerComponent.ActivateBulletTime(1.0f)); fxPlayed2 = true; } if (lastWave) { lastWave = false; } } //initialize NPC Spawner objects for spawning of this wave for (int i = 0; i < NpcSpawners.Count; i++) { NpcSpawners[i].NPCPrefab = waves[waveNumber - 1].NpcTypes[i]; NpcSpawners[i].NpcsToSpawn = waves[waveNumber - 1].NpcCounts[i]; NpcSpawners[i].maxActiveNpcs = waves[waveNumber - 1].NpcLoads[i]; NpcSpawners[i].spawnDelay = waves[waveNumber - 1].NpcDelay[i]; NpcsToSpawn += NpcSpawners[i].NpcsToSpawn; NpcSpawners[i].pauseSpawning = true; NpcSpawners[i].spawnedNpcAmt = 0; NpcSpawners[i].huntPlayer = true; NpcSpawners[i].unlimitedSpawning = false; } //spawn wave while (true) { WarmupUIText1.rectTransform.anchoredPosition = warmupTextPos1Orig; WarmupUIText2.rectTransform.anchoredPosition = warmupTextPos2Orig; warmupTextPos1 = warmupTextPos1Orig; warmupTextPos2 = warmupTextPos2Orig; if (startTime + 3.00 < Time.time) { WarmupText.waveComplete = false; WarmupTextShadow.waveComplete = false; countDown -= Time.deltaTime; WarmupText.warmupGui = countDown; WarmupTextShadow.warmupGui = countDown; } WarmupUIText1.enabled = true; WarmupUIText2.enabled = true; WarmupUIText1.color = tempColor; WarmupUIText2.color = tempColor2; //start spawning NPCs for this wave if (countDown <= 0.0f) { if (waveStartFx && !fxPlayed) { for (int i = 0; i < NpcSpawners.Count; i++) { NpcSpawners[i].pauseSpawning = false; } WarmupText.waveBegins = true; WarmupTextShadow.waveBegins = true; fxPlayed = true; fxPlayed2 = false; asource.PlayOneShot(waveStartFx, 1.0f); } } if (countDown <= -2.75f) { StartCoroutine(FadeWarmupText()); fxPlayed = false; yield break; } yield return(null); } }