Ejemplo n.º 1
0
    private IEnumerator FadePauseMenu(bool e)
    {
        if (isTransitioningPause)
        {
            yield break;
        }

        isPaused             = e;
        isTransitioningPause = true;

        if (e)
        {
            RestrictionManager.pauseMenu = true;
            pauseMenu.SetActive(true);
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;

            if (!Topan.Network.isConnected)
            {
                AudioListener.pause = true;
                lastTimeScale       = Time.timeScale;
                DarkRef.SetTimeScale(0f);
            }

            while (pausePanel.alpha < 1f)
            {
                pausePanel.alpha = Mathf.Clamp01(Mathf.MoveTowards(pausePanel.alpha, 1f, Time.unscaledDeltaTime * 7f));
                yield return(null);
            }
        }
        else
        {
            AudioListener.pause = false;
            DarkRef.SetTimeScale(lastTimeScale);
            StartCoroutine(FadeSettings(false));

            while (pausePanel.alpha > 0f)
            {
                pausePanel.alpha = Mathf.Clamp01(Mathf.MoveTowards(pausePanel.alpha, 0f, Time.unscaledDeltaTime * 7f));
                yield return(null);
            }

            pauseMenu.SetActive(false);
            RestrictionManager.pauseMenu = false;

            if (GeneralVariables.player != null)
            {
                yield return(null);

                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible   = false;
            }
        }

        isTransitioningPause = false;
    }