Example #1
0
    /// <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;
        }
    }
Example #2
0
 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;
         }
     }
 }
Example #3
0
 public static void TogglePause()
 {
     IsPaused = !IsPaused;
     PauseStateChanged?.Invoke(IsPaused);
 }
Example #4
0
 private void OnPaused(PauseStateChanged e)
 {
     Time.timeScale = e.IsPaused ? 0 : 1;
     IsPaused       = AudioListener.pause = e.IsPaused;
 }