/// <summary> /// Goes in and out of paused state, enabling and disabling required components. Raises the PauseStateChanged event if so specified. /// </summary> public void ChangePauseState(bool isPaused, bool shouldRaiseEvent) { IsGamePaused = isPaused; if (shouldRaiseEvent) { PauseStateChanged?.Invoke(); } playerController.enabled = !isPaused; PlacementManager.Instance.enabled = !isPaused; Cursor.visible = isPaused; if (isPaused) { Time.timeScale = 0; Cursor.lockState = CursorLockMode.None; } else { Time.timeScale = 1; Cursor.lockState = CursorLockMode.Locked; } }
private void TogglePause() { isPaused = !isPaused; PauseStateChanged?.Invoke(isPaused); if (isPaused) { Time.timeScale = 0f; foreach (Commander commander in grid.Commanders) { foreach (CombatUnit unit in commander.units) { unit.PathShown = false; } } } else { Time.timeScale = 1f; foreach (CombatUnit unit in units) { unit.PathShown = true; } } }
public static void TogglePause() { IsPaused = !IsPaused; PauseStateChanged?.Invoke(IsPaused); }
private void OnPaused(PauseStateChanged e) { Time.timeScale = e.IsPaused ? 0 : 1; IsPaused = AudioListener.pause = e.IsPaused; }