public void SetPhase(WavePhase _phase) { currPhaseTick = 0; currWavePhase = _phase; switch (_phase) { case WavePhase.Attack: { currPhaseFrom = 0.0f; currPhaseTo = 1.0f; currPhaseTicks = 1000 * Settings.Attack_MS; break; } case WavePhase.Decay: { currPhaseFrom = 1.0f; currPhaseTo = Settings.SustainLevel; currPhaseTicks = 1000 * Settings.Decay_MS; break; } case WavePhase.Sustain: { currPhaseFrom = Settings.SustainLevel; currPhaseTo = Settings.SustainLevel; currPhaseTicks = 0; break; } case WavePhase.Release: { if (currGain == 0) { SetPhase(WavePhase.Mute); break; } currPhaseFrom = currGain; currPhaseTo = 0; currPhaseTicks = 1000 * Settings.Release_MS; break; } case WavePhase.Mute: { currPhaseFrom = 0; currPhaseTo = 0; currPhaseTicks = 0; break; } } Process(0); // SetGain(currPhaseFrom); }
public void Retreat() //Once this is called, all living goons go to a selected destination and once reached will despawn and //tell the B I G B O S S they have departed { waveTimer = 0; timerDisplay.text = "The enemy is retreating!"; currentPhase = WavePhase.Retreat; foreach (GameObject goon in goonsAlive)//For every goon alive... { goon.GetComponent <NavMeshAgent>().SetDestination(transform.position); } }
public void BeginWave()//Repeatable ad infinitum { currentPhase = WavePhase.Fight; waveTimer = 0; //Reset wave timer waveOver = false; //Wave has begun passiveTimer = 0; //Reset passive timer currentWave = currentWave + 1; //Move to next wave if (gcInstance.playerCount > 0) //If anyone is playing -- Mostly for early game dev since no main menu yet { goonsAllowed = (int)currentWave * 6; //6, 12, for (int i = 0; i < goonsAllowed; i++) //Loop until all allowed goons have been spawned { GameObject goon = Instantiate(goonPrefab, transform); //Spawn goon goonsAlive.Add(goon); //Add to list of living goons, to be removed as they die, and recalled at Retreat phase } } GiveTarget();//Once all goons are instantiated set them off }
void Start() { gcInstance = GameManager.gcInstance; currentWave = WaveState.WaveZero;//Start with no wave on currentPhase = WavePhase.Passive; targets = new List <GameObject>(); waveOver = true; waveTimer = 0; if (maxWaveTime <= 0) { maxWaveTime = 30;//Defaults to 30 seconds } passiveTimer = 0; if (maxPassiveTime <= 0) { maxPassiveTime = 10;//Defaults to 10 seconds } }
void Update() { #region Debug Stuff Debug.Log(currentWave);//Show me the W A V E if (Input.GetKeyDown(KeyCode.Space) && waveOver && currentWave < WaveState.WaveFive) //Debug wave starting and only if the wave hasnt started and theres only been 4 { BeginWave(); } if (Input.GetKeyDown(KeyCode.LeftShift) && !waveOver)//Debug retreat { Retreat(); } #endregion goonCountDisplay.text = goonsAlive.Count.ToString(); #region PassivePhase if (currentPhase == WavePhase.Passive) //if its passive phase { if (waveOver && currentWave < WaveState.WaveFive && passiveTimer >= maxPassiveTime) //If the wave is over and there are still waves available... { BeginWave(); } passiveTimer += Time.deltaTime; timerDisplay.text = "Next wave in " + Mathf.RoundToInt(maxPassiveTime - passiveTimer) + " seconds..."; } #endregion #region CombatPhase if (!waveOver && currentPhase == WavePhase.Fight)//If the wave has not ended and they are not retreating { GiveTarget(); waveTimer += Time.deltaTime; timerDisplay.text = "Wave ends in " + Mathf.RoundToInt(maxWaveTime - waveTimer) + " seconds..."; } if (waveTimer >= maxWaveTime)//If the wave has gone on for the max wave time... { Retreat(); } #endregion #region RetreatPhase if (currentPhase == WavePhase.Retreat)//If its retreat phase, loop through all goons and remove them as they escape { //The above if is there to make script more efficient foreach (GameObject goon in goonsAlive) { if (goon.GetComponent <NavMeshAgent>().destination == transform.position) //if they are retreating and have reached their destination/the exit { RemoveGoon(goon); } } } #endregion if (goonsAlive.Count <= 0) //if there are no living goons or all goons have fled { waveOver = true; //The wave is over boys currentPhase = WavePhase.Passive; } }