Exemplo n.º 1
0
    private void OnTimeOutHandler()
    {
        _levelInfoLoader.AddPlayerResult("MY NAME", _timer.CurrentTime, _levelManager.LevelName);

        GameResultsView gameResultsView = Instantiate(_gameResultPrefab, _container);

        gameResultsView.Initialize(_levelManager.CurentLevel);

        _timer.Pause(true);
    }
Exemplo n.º 2
0
    private void OnClickHandler()
    {
        if (_doubleBonus)
        {
            _scores += 2;
            _progressBar.GetComponent <Image>().fillAmount += 1f / _maxScore;
        }
        else
        {
            _scores += 1;
        }


        if (_scores >= _maxScore)
        {
            _scores = _maxScore;
            _levelInfoLoader.AddPlayerResult("MY NAME", _timer.CurrentTime, _levelManager.LevelName);
            GameResultsView gameResultsView = Instantiate(_gameResultPrefab, _container);
            gameResultsView.Initialize(_levelManager.CurentLevel);
            _timer.Pause(true);
        }

        _currentScoreText.text = _scores.ToString() + "/" + _maxScore.ToString();

        CheckBonuses();

        if (_bigSizeBonus)
        {
            _clickable.GetComponent <Transform>().transform.localScale = new Vector3(2, 2, 1);
        }
        else
        {
            _clickable.GetComponent <Transform>().transform.localScale = new Vector3(1, 1, 1);
        }

        _progressBar.GetComponent <Image>().fillAmount += 1f / _maxScore;
        _clickSound.Play();

        _clickable.SetPosition(GetRandomPosition());

        float randomBonus = UnityEngine.Random.value;

        if (randomBonus < 0.2f)
        {
            System.Random random = new System.Random();
            int           bonus  = random.Next(0, 3);
            if (bonus == 0)
            {
                _bigBonusItem.SetActive(true);
                _bigBonusItem.SetPosition(GetRandomPosition());
            }
            else if (bonus == 1)
            {
                _freezeBonusItem.SetActive(true);
                _freezeBonusItem.SetPosition(GetRandomPosition());
            }
            else if (bonus == 2)
            {
                _doubleBonusItem.SetActive(true);
                _doubleBonusItem.SetPosition(GetRandomPosition());
            }
        }
    }