Beispiel #1
0
    private void Update()
    {
        if (GameManager.inst.State == GameManager.GameState.InGame)
        {
            _time           = Mathf.Max(0.0f, _time - TimeManager.deltaTime);
            _timerText.text = _time.ToString("0.0");

            if (_time <= .0f)
            {
                int index = SceneManager.GetActiveScene().buildIndex;
                if (_bestScores[index] < _score)
                {
                    _bestScores[index] = _score;
                }

                _yourScore_Score.text = "" + _score;
                //if (_score > 0)
                {
                    _yourName_Score.gameObject.SetActive(true);
                    string username = HandleTextFile.ReadString(GameManager.username_path);
                    username             = Regex.Replace(username, @"[^A-Za-z0-9]+", "");
                    _yourName_Score.text = string.IsNullOrEmpty(username) ? "anonymous" : username;
                    //_keyBoard.SetActive(true);
                    //HSController.inst.PostScores("anonymous", _score);
                }
                //else _yourName_Score.gameObject.SetActive(false);

                DisplayGameOverMenu();
            }
            else if ((Input.GetButtonDown("Back0") && !Input.GetButton("Back1")) || (Input.GetButtonDown("Back1") && !Input.GetButton("Back0")))
            {
                _compatibility.SetVisibleInGame();
            }
            else if ((Input.GetButtonUp("Back0") && !Input.GetButton("Back1")) || (Input.GetButtonUp("Back1") && !Input.GetButton("Back0")))
            {
                _compatibility.Hide();
            }
        }
        if ((Input.GetButtonUp("Start") || Input.GetKeyDown(KeyCode.Escape)) && GameManager.inst.State != GameManager.GameState.Menu)
        {
            if (GameManager.inst.State == GameManager.GameState.InGame)
            {
                DisplayPauseMenu();
            }
            else if (GameManager.inst.State == GameManager.GameState.Paused)
            {
                HidePauseMenu();
            }
        }
        else if (Input.GetButtonUp("B") && GameManager.inst.State != GameManager.GameState.InGame && !keyboardDisplay)
        {
            if (GameManager.inst.State == GameManager.GameState.Paused)
            {
                HidePauseMenu();
            }
            else if (_crtReturnButton != null) //is in submenu
            {
                _crtReturnButton.onClick.Invoke();
                _crtReturnButton = null;
            }
        }

        #if UNITY_EDITOR
        if (Input.GetKeyDown("x"))
        {
            _score += 2;
        }
        #endif
    }