Example #1
0
    private void HoldQuitTimer()
    {
        if (!_quitBar.gameObject.activeSelf)
        {
            _quitBar.gameObject.SetActive(true);
        }

        _holdQuitTick += Time.unscaledDeltaTime;
        if (_holdQuitTick >= _holdQuitTime)
        {
            _holdQuitTick = 0;

            ButtonHandler.QuitButton = false;

            _quitBar.localScale = _quitBarSize;
            _quitBar.gameObject.SetActive(false);

            if (CurrentGameModeState == GameModeState.Gameplay)
            {
                if (Time.timeScale != 1)
                {
                    Time.timeScale = 1;
                }

                CurrentGameModeState = GameModeState.Start;
                CurrentPlayMode      = PlayMode.None;

                _scoreboardScript.ResetStats();

                ButtonHandler.DisableAllButtons();

                _titleAnimationScript.Enable(true);

                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }
            else if (CurrentGameModeState == GameModeState.Info)
            {
                CurrentGameModeState = GameModeState.Start;
                if (_helpText.activeSelf)
                {
                    ButtonHandler.HelpButton = false;
                    _helpText.SetActive(false);
                }
                else if (_creditsText.activeSelf)
                {
                    ButtonHandler.CreditsButton = false;
                    _creditsText.SetActive(false);
                }
                _scoreboardScript.EnableScoreboardGui(true);
            }
            else
            {
                Application.Quit();
            }
        }
        else
        {
            float scale = (Screen.width / _holdQuitTime) * Time.unscaledDeltaTime;
            _quitBar.localScale += new Vector3(scale, 0);
        }
    }