public void MoveTrigger(AxisEventData data) { string result = mText.text; switch (data.moveDir) { case MoveDirection.Down: case MoveDirection.Up: result = result.Replace("< ", ""); result = result.Replace(" >", ""); option = NextOption(); if (option == PauseOption.Resume) { result = result.Replace("Resume", "< Resume >"); } else if (option == PauseOption.Quit) { result = result.Replace("Quit", "< Quit >"); } mText.text = result; break; default: break; } }
private void Pause() { // Debug.Log("Pause Game") EventBus.PublishEvent(new PauseMenuEngagedEvent()); currentPauseOption = PauseOption.Resume; // Debug.Log("Current Pause Option: " + currentPauseOption); EventBus.PublishEvent(new SwitchFocusToResumeOptionEvent()); foreach (Rigidbody rb in FindObjectsOfType <Rigidbody>()) { rb.Sleep(); } }
void doPauseMenuAction(PauseOption action) { if (action == PauseOption.CONTINUE) { game_paused = false; CameraController.cam_control.unpause(); } else if (action == PauseOption.RESTART) { AudioController.audioPlayer.audio.Stop(); SceneManager.LoadScene(SceneManager.GetActiveScene().name); } else if (action == PauseOption.EXIT) { AudioController.audioPlayer.audio.Stop(); AudioController.audioPlayer.exitSound(); sound_waiting = true; Invoke("loadStartMenu", 0.75f); } }
public override void DoUpdate() { // For now, restart is a cheat executed from the pause menu if (Input.GetKey(KeyCode.BackQuote) && Input.GetKeyDown(KeyCode.R)) { Restart(); return; } // Hitting Esc resumes the game if (Input.GetKeyUp(KeyCode.Escape) || player.GetButtonUp("Pause") || player.GetButtonUp("Back")) { Resume(); } // Hitting enter executes the current pause option else if (Input.GetKeyUp(KeyCode.Return) || (player.GetButtonUp("Interact") && !Input.GetMouseButton(0))) { // Debug.Log("Return"); switch (currentPauseOption) { case PauseOption.Restart: Restart(); break; case PauseOption.Resume: Resume(); break; case PauseOption.Quit: Quit(); break; } } // Hitting the arrow keys (including WASD) scrolls selection through Pause Menu options else { bool selectionSwitched = false; if (Input.GetKeyDown(KeyCode.UpArrow) && !Input.GetKey(KeyCode.W) || Input.GetKeyDown(KeyCode.W) && !Input.GetKey(KeyCode.UpArrow) || player.GetButtonDown("Pause Menu Up")) { currentPauseOption = (PauseOption)(((int)currentPauseOption - 1 + 3) % 3); // + 2) % 2); // Debug.Log("Current Pause Option: " + currentPauseOption); selectionSwitched = true; } else if (Input.GetKeyDown(KeyCode.DownArrow) && !Input.GetKey(KeyCode.S) || Input.GetKeyDown(KeyCode.S) && !Input.GetKey(KeyCode.DownArrow) || player.GetButtonDown("Pause Menu Down")) { currentPauseOption = (PauseOption)(((int)currentPauseOption + 1) % 3); // % 2); // Debug.Log("Current Pause Option: " + currentPauseOption); selectionSwitched = true; } if (selectionSwitched) { switch (currentPauseOption) { case PauseOption.Restart: EventBus.PublishEvent(new SwitchFocusToRestartOptionEvent()); break; case PauseOption.Resume: EventBus.PublishEvent(new SwitchFocusToResumeOptionEvent()); break; case PauseOption.Quit: EventBus.PublishEvent(new SwitchFocusToQuitOptionEvent()); break; } } } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("Pause")) { menuSound1.Play(); _gamePaused = !_gamePaused; Time.timeScale = _gamePaused ? 0f : 1f; _pauseCanvas.SetActive(_gamePaused); if (_gamePaused) { showControls = false; controlImage.SetActive(false); currentSelection = 0; } } if (_gamePaused) { if (!showControls) { float newYInput = Input.GetAxis("Vertical"); if (Input.GetKeyDown(KeyCode.W) || (newYInput > 0.1f && lastYInput <= 0.1f)) { if (--currentSelection < 0) { currentSelection = PauseOption.NUMBER_OF_PAUSE_OPTIONS - 1; } menuSound2.Play(); } else if (Input.GetKeyDown(KeyCode.S) || (newYInput < -0.1f && lastYInput >= 0.1f)) { if (++currentSelection >= PauseOption.NUMBER_OF_PAUSE_OPTIONS) { currentSelection = 0; } menuSound2.Play(); } lastYInput = newYInput; } Vector3 selectPos = selector.transform.position; selectPos.y = textOptions[(int)currentSelection].transform.position.y; selector.transform.position = selectPos; if (commitAction) { commitAction = false; menuSound1.Play(); switch (currentSelection) { case PauseOption.Continue: _gamePaused = false; Time.timeScale = 1f; _pauseCanvas.SetActive(false); break; case PauseOption.Home: playerController.transform.position = Vector3.zero; playerController.OnPlatformReturn(); PlatformReturn.LastPlatformTouched = null; _gamePaused = false; Time.timeScale = 1f; _pauseCanvas.SetActive(false); break; case PauseOption.Controls: showControls = !showControls; controlImage.SetActive(showControls); break; case PauseOption.Credits: creditsHolder.SetActive(!creditsHolder.activeSelf); break; case PauseOption.Exit: Time.timeScale = 1f; SceneManager.LoadScene("Title"); break; case PauseOption.Quit: Application.Quit(); break; default: break; } } if (Input.GetButtonDown("Submit")) { // When the submit button is pressed, execute the action on the NEXT frame commitAction = true; } } }