Example #1
0
    private void UpdateScore()
    {
        if (_gameStopped && !_timeAttack)
        {
            Time.timeScale = 0f;
            ObjectivesEndScreen.ShowScreen(false, _timeAttack, _score, _longestChain);
        }

        if (ObjectiveScore > 0)
        {
            var objectivesLeft = 0;
            foreach (var objective in _objectives)
            {
                objectivesLeft += objective.ObjectiveCount;
            }

            if (_score >= ObjectiveScore && objectivesLeft == 0)
            {
                ObjectivesEndScreen.ShowScreen(true, _timeAttack, _score, _longestChain);

                ProgressHandler.SaveLevelProgress(_progressHandler.GetScore() + _score,
                                                  (CurrentLevelIndex == _progressHandler.GetLevelProgress())
                        ? (CurrentLevelIndex + 1)
                        : _progressHandler.GetLevelProgress());

                Time.timeScale = 0f;
                _gameStopped   = true;
            }
        }

        _boardUiHandler.UpdatePanel(_timeAttack, _score, _longestChain);
    }
Example #2
0
    private void Start()
    {
        Time.timeScale = 1f;

        _levels = _levelHolder.GetComponentsInChildren <LevelMarker>().OrderBy(marker => marker.LevelIndex).ToArray();

        _progressHandler.Load();
        _scoreText.text = string.Format("Score: {0}", _progressHandler.GetScore());

        var levelProgress = _progressHandler.GetLevelProgress();

        var i = 0;

        _lineRenderer.positionCount = (levelProgress < _levels.Length) ? levelProgress + 1 : _levels.Length;
        _lineRenderer.startWidth    = 0.1f;
        _lineRenderer.endWidth      = 0.1f;

        foreach (var level in _levels)
        {
            if (i < levelProgress)
            {
                level.GetComponentInChildren <Image>().sprite =
                    _levelBeaten;
                _lineRenderer.SetPosition(i, level.transform.position);
            }

            if (i == levelProgress)
            {
                level.GetComponentInChildren <Image>().sprite = _levelOpen;
                _lineRenderer.SetPosition(i, level.transform.position);
            }

            if (i > levelProgress)
            {
                level.GetComponentInChildren <Image>().sprite = _levelClosed;
            }

            i++;
        }
    }