public void SetState(State state) { UiManager.Instance.State = state; switch (state) { case State.Play: Time.timeScale = 1f; UiManager.Instance.MainMenu.group.interactable = false; environmentNoise.volume = normalEnvirVol; if (Player.WormHead.dirtAudioSource.isVirtual) { Player.WormHead.dirtAudioSource.UnPause(); } else { Player.WormHead.dirtAudioSource.Play(); } break; case State.InMenu: Time.timeScale = 0f; UiManager.Instance.MainMenu.group.interactable = true; environmentNoise.volume = normalEnvirVol; break; case State.Dead: Player.StreakEggShell = 0; Time.timeScale = 0f; if (UiManager.Instance.BestSessionScore < Player.Score) { UiManager.Instance.BestSessionScore = Player.Score; } UiManager.Instance.Death(); cameraSoundSource.PlayOneShot(deathEffect); environmentNoise.volume = 0f; Player.WormHead.dirtAudioSource.Stop(); break; case State.Pause: Time.timeScale = 0f; environmentNoise.volume = muffledEnvirVol; Player.WormHead.dirtAudioSource.Pause(); break; } MusicManager.SwitchMusic(state); }
private IEnumerator TransitionToNextTurn() { TransitionInProgress = true; pauseUI.SetActive(false); HidePlaneUI(); SoundEffectManager.instance.PlayEffect("Jet Engine"); List <Plane> rejectedPlanes = new List <Plane>(); // These planes will have a negative impact on your relationship with the country List <Plane> removedPlanes = new List <Plane>(); // This is used because you can't modify a list you are iterating through. foreach (Plane plane in planes) { if (plane.country.IsHostile) // Any remaining hostile planes can't be selected and go back home asap { MakePlaneLeave(plane); removedPlanes.Add(plane); } else if (plane.isSelected) { MakePlaneLand(plane); removedPlanes.Add(plane); } else if (plane.RemainingWaits > 0) { MakePlaneWait(plane); } else { MakePlaneLeave(plane); removedPlanes.Add(plane); rejectedPlanes.Add(plane); } } foreach (Plane plane in removedPlanes) { planes.Remove(plane); } planeSelection.DeselectAll(); airportManager.ClearAirportRunways(); // send in new planes SpawnNewPlanes(); // Wait until all animations are complete yield return(new WaitForSeconds(transitionDuration)); // Decrease your relationship with any countries you have rejected planes from THEN check for game over foreach (Plane plane in rejectedPlanes) { FaceConsequencesForRejection(plane); } CheckForGameOver(); ShowPlaneUI(); pauseUI.SetActive(true); planeSelection.UpdateEndTurnButton(); turnNumber++; turnCounter.text = "Turn " + turnNumber + " of " + turnsForWin; popupScheduler.ShowPopupsForTurn(turnNumber); TransitionInProgress = false; musicManager.SwitchMusic(turnNumber); Debug.Log("Turn number " + turnNumber); }