Example #1
0
    public void PauseGame()
    {
        if (Input.GetKeyDown(KeyCode.Escape) && !pausedGame)
        {
            switch (ScenesManager.Instance.GetCurrentSceneNumber())
            {
            case 1:                     //main menu, do nothing
                break;

            case 2:                     //intro, skip
                NextLevel();
                break;

            default:                     //game levels, pause
                hudMobile.ShowPauseMessage();
                pausedGame = true;
                DOTween.To(value => Time.timeScale = value, 1.0f, 0.0f, 1.0f).SetEase(Ease.Linear).SetUpdate(true);
                cutscene.SwitchBlurEffects(pausedGame);
                sounds.PitchBackgroundMusic(pausedGame);
                Cursor.visible   = true;
                Cursor.lockState = CursorLockMode.Confined;
                break;
            }
        }
        else if ((Input.GetKeyDown(KeyCode.Escape) && pausedGame) || continueButton)
        {
            hudMobile.HidePauseMessage();
            pausedGame     = false;
            continueButton = false;
            cutscene.SwitchBlurEffects(pausedGame);
            DOTween.To(value => Time.timeScale = value, 0.0f, 1.0f, 1.0f).SetEase(Ease.Linear).SetUpdate(true);
            sounds.PitchBackgroundMusic(pausedGame);
            Cursor.visible   = false;
            Cursor.lockState = CursorLockMode.Locked;
        }
    }