Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (State == GameLogicState.Play)
        {
            checkMatch();

            _colorPoints = Mathf.Max(_colorPoints - Time.deltaTime * 50, 10);

            _time -= Time.deltaTime;

            _timeTransform.anchorMax = new Vector2(_time / _maxTime, _timeTransform.anchorMax.y);

            if (!_timeCritical && _time / _maxTime <= 0.2)
            {
                _timeCritical = true;
                _timeAnimator.SetBool("critical", true);
            }
            if (_timeCritical && _time / _maxTime > 0.2)
            {
                _timeCritical = false;
                _timeAnimator.SetBool("critical", false);
            }

            if (_time <= 0.0f)
            {
                GameMixer.Instance.ClearColor();
                State                     = GameLogicState.End;
                _mainText.text            = "FIN";
                _endCanvas.alpha          = 1.0f;
                _endCanvas.interactable   = true;
                _endCanvas.blocksRaycasts = true;

                if (string.IsNullOrEmpty(Settings.PlayerName))
                {
                    _sendScoreText.text = "please set a player name in the main menu to submit high scores";
                }
                else
                {
                    _sendScoreText.text = "submitting score...";

                    StartCoroutine(HighscoreManager.PostScore(Settings.PlayerName, _score, (int)Settings.Mode, Application.isMobilePlatform, () =>
                    {
                        _sendScoreText.text = "score sucessfully submitted" + Environment.NewLine + "loading placement...";

                        StartCoroutine(HighscoreManager.GetPlacement(Settings.PlayerName, (int)Settings.Mode, Application.isMobilePlatform, s =>
                        {
                            _sendScoreText.text = "score sucessfully submitted" + Environment.NewLine + s;
                        }, s =>
                        {
                            _sendScoreText.text = "score sucessfully submitted" + Environment.NewLine + s;
                        }));
                    }, s =>
                    {
                        _sendScoreText.text = s;
                    }));
                }
            }
        }
    }