Пример #1
0
        private void UpdateLevel(int level, int score)
        {
            _score.text = FormatHelper.FormatValue(score);

            var current = GameConfiguration.GetLevelSettings(level);

            if (current != null)
            {
                _currentLevel.gameObject.SetActive(true);
                _currentLevel.text = level.ToString();
                UpdateLevelProgress(score, current);

                var nextLevel = level + 1;
                var next      = GameConfiguration.GetLevelSettings(nextLevel);
                if (next != null)
                {
                    _nextLevel.gameObject.SetActive(true);
                    _nextLevel.text = nextLevel.ToString();
                }
                else
                {
                    _nextLevel.gameObject.SetActive(false);
                }
            }
            else
            {
                _currentLevel.gameObject.SetActive(false);
                _nextLevel.gameObject.SetActive(false);
            }
        }
Пример #2
0
        private void ApplyStartSpeed(int level)
        {
            var levelSettings = GameConfiguration.GetLevelSettings(level);

            if (levelSettings != null)
            {
                _speed = levelSettings.PathSettings.StartSpeed;
            }
        }
Пример #3
0
        private void UpdateLevelProgress(int score)
        {
            var levelSettings = GameConfiguration.GetLevelSettings(GameController.Instance.GameSession.Level);

            if (levelSettings != null)
            {
                _progress.fillAmount = (float)score / levelSettings.Score;
            }
        }
Пример #4
0
        public override void Activate()
        {
            var level = GameConfiguration.GetLevelSettings(GameController.Instance.GameSession.Level);

            if (level != null)
            {
                _multiplier = level.LineSettings.ScoreMultiplier;
                _text.text  = string.Format("x{0}", _multiplier);
            }
        }
Пример #5
0
        private void UpdateLevelProgress(int score, LevelSettings current)
        {
            var previousLevelScore = 0;
            var previousLevel      = GameConfiguration.GetLevelSettings(current.Level - 1);

            if (previousLevel != null)
            {
                previousLevelScore = previousLevel.Score;
            }

            _progress.fillAmount = (float)(score - previousLevelScore) / (current.Score - previousLevelScore);
        }
Пример #6
0
        private void Update()
        {
            if (!_isActive)
            {
                return;
            }

            while (_lines.Count < GameConfiguration.Instance.LinesCount)
            {
                SpawnLine();
            }

            for (var i = _lines.Count - 1; i >= 0; i--)
            {
                var line = _lines[i];
                if (line.Position.z < -GameConfiguration.Instance.LinesVisibleRange)
                {
                    line.Deactivate();
                    _lines.RemoveAt(i);
                }
                else
                {
                    var levelSettings = GameConfiguration.GetLevelSettings(GameController.Instance.GameSession.Level);
                    if (levelSettings != null)
                    {
                        if (levelSettings.PathSettings.SpeedIncreaseTime > 0f && Time.time - _time > levelSettings.PathSettings.SpeedIncreaseTime)
                        {
                            _speed = Mathf.Clamp(_speed * (1 + levelSettings.PathSettings.SpeedMultiplier), levelSettings.PathSettings.StartSpeed, levelSettings.PathSettings.MaxSpeed);
                            _time  = Time.time;
                            Debug.Log(string.Format("Path speed change: {0}", _speed));
                        }

                        line.Position += Vector3.back * _speed * Time.deltaTime;
                    }
                }
            }
        }
Пример #7
0
        private void ProcessPlatform(Platform platform)
        {
            if (platform.Color == _color)
            {
                if (GameController.Instance.GameState == GameState.Play)
                {
                    var level = GameConfiguration.GetLevelSettings(GameController.Instance.GameSession.Level);
                    if (level != null)
                    {
                        var score = level.LineSettings.PlatformScore * GameController.Instance.GameSession.ScoreMultiplier;
                        GameController.Instance.GameSession.AddScorePoints(score);

                        var hint = _hintsSpawner.Spawn() as Hint;
                        if (hint != null)
                        {
                            hint.Place(transform.position, platform.BaseTransform, score);
                        }
                    }
                }
            }
            else
            {
                if (!_isInvincible)
                {
                    GameController.Instance.GameSession.SubtractLive();
                }
            }

            var blot = _blotSpawner.Spawn() as Blot;

            if (blot != null)
            {
                blot.Place(transform.position, platform.BaseTransform, _color);
            }

            platform.Trigger();
        }
Пример #8
0
        private void SpawnLine()
        {
            var level = GameConfiguration.GetLevelSettings(GameController.Instance.GameSession.Level);

            if (level != null)
            {
                var line = _linesSpawner.Spawn() as Line;
                if (line != null)
                {
                    var position = Vector3.zero;

                    if (_lines.Count > 0)
                    {
                        position    = _lines[_lines.Count - 1].transform.position;
                        position.x  = Random.Range(-level.PathSettings.MaxXShift, level.PathSettings.MaxXShift);
                        position.z += Random.Range(level.PathSettings.MinPlatformDistance, level.PathSettings.MaxPlatformDistance);
                    }

                    Pickup pickup = null;
                    if (level.LineSettings.PickupSpawnStep > 0 && _linesStep >= level.LineSettings.PickupSpawnStep)
                    {
                        _linesStep = 0;
                        pickup     = _pickupsSpawner.GetNextPickup();
                    }
                    else
                    {
                        _linesStep++;
                    }

                    line.Position = position;
                    line.Setup(_lines.Count == 0, level, _color, pickup);

                    _lines.Add(line);
                }
            }
        }