/// <summary> /// Opens or closes the pause menu /// </summary> /// <param name="_open">If TRUE opens, otherwise closes</param> public void OpenMenu(bool _open) { IsMenuOpen = _open; // Set toggles BtMusic.Toggle(AudioManager.I.MusicEnabled); BtFx.Toggle(AppManager.I.GameSettings.HighQualityGfx); if (_open) { timeScaleAtMenuOpen = Time.timeScale; Time.timeScale = 0; if (AppManager.I.CurrentGameManagerGO != null) { AppManager.I.CurrentGameManagerGO.SendMessage("DoPause", true, SendMessageOptions.DontRequireReceiver); } openMenuTween.timeScale = 1; openMenuTween.PlayForward(); AudioManager.I.PlaySfx(Sfx.UIPauseIn); } else { Time.timeScale = timeScaleAtMenuOpen; logoBobTween.Pause(); openMenuTween.timeScale = 2; // Speed up tween when going backwards if (AppManager.I.CurrentGameManagerGO != null) { AppManager.I.CurrentGameManagerGO.SendMessage("DoPause", false, SendMessageOptions.DontRequireReceiver); } openMenuTween.PlayBackwards(); AudioManager.I.PlaySfx(Sfx.UIPauseOut); } }
void Start() { menuBts = this.GetComponentsInChildren <MenuButton>(true); foreach (MenuButton bt in menuBts) { MenuButton b = bt; b.Bt.onClick.AddListener(() => OnClick(b)); } BtMusic.Toggle(AudioManager.I.MusicEnabled); BtFx.Toggle(AppManager.I.GameSettings.HighQualityGfx); }
/// <summary> /// Callback for button clicks /// </summary> void OnClick(MenuButton _bt) { if (SceneTransitioner.IsPlaying) { return; } if (_bt == BtPause) { OpenMenu(!IsMenuOpen); } else if (!openMenuTween.IsPlaying()) // Ignores pause menu clicks when opening/closing menu { switch (_bt.Type) { case MenuButtonType.Back: // Exit OpenMenu(false); NavigationManager.I.ExitAndGoHome(); break; case MenuButtonType.MusicToggle: // Music on/off AudioManager.I.ToggleMusic(); BtMusic.Toggle(AudioManager.I.MusicEnabled); break; case MenuButtonType.FxToggle: // FX on/off AppManager.I.ToggleQualitygfx(); BtFx.Toggle(AppManager.I.GameSettings.HighQualityGfx); break; case MenuButtonType.Credits: Credits.Show(true); break; case MenuButtonType.Continue: // Resume OpenMenu(false); break; } } }
void OnClick(MenuButton bt) { switch (bt.Type) { case MenuButtonType.MusicToggle: // Music on/off AudioManager.I.ToggleMusic(); BtMusic.Toggle(AudioManager.I.MusicEnabled); break; case MenuButtonType.FxToggle: // FX on/off AppManager.I.ToggleQualitygfx(); BtFx.Toggle(AppManager.I.GameSettings.HighQualityGfx); break; case MenuButtonType.Continue: HomeMngr.Play(); break; case MenuButtonType.Credits: CreditsWindow.Open(); break; } }