private IEnumerator GenerateMap()
        {
            _previousPart = null;
            for (var i = 0; i < _config.MaxLevelParts; i++)
            {
                _previousPart = GeneratePart(_previousPart);
            }

            while (true)
            {
                if (SchneggePastPart(0))
                {
                    _previousPart = GeneratePart(_previousPart);
                    RemovePart(0);
                }

                if (SchneggeBeforePart(0))
                {
                    RegeneratePreviousPart(_parts[0]);
                    _previousPart = _parts[_parts.Count - 2];
                    RemovePart(_parts.Count - 1);
                }

                yield return(new WaitForSeconds(_config.UpdateInterval));
            }
        }
Beispiel #2
0
        private void Setup()
        {
            _levelPoints          = new List <Vector2>();
            _flyingIslandMapping  = new Dictionary <Color, List <Vector2> >();
            _attackTriggerMapping = new Dictionary <Color, List <Vector2> >();

            _generatedLevel = CreateChildObject(_importedTexture.name, null).AddComponent <LevelPart>();
            _generatedLevel.Reset();
        }
        private void ValidateScript()
        {
            if (_part != null)
            {
                return;
            }

            _part = (LevelPart)target;
        }
        private void RegeneratePreviousPart(LevelPart followingPart)
        {
            _currentLevelIndex--;

            var part = RegeneratedPartIndex < _config.TutorialParts.Length ?
                       RegenerateTutorialPart() :
                       RegenerateRandomPart();

            part.SetPositionAsPrevious(followingPart);

            _parts.Insert(0, part);
        }
Beispiel #5
0
        public void SetPositionAsPrevious(LevelPart nextPart)
        {
            if (nextPart == null)
            {
                gameObject.transform.position = Vector3.zero - LevelEndPoint.position;
                return;
            }

            var ownOffset   = gameObject.transform.position - LevelEndPoint.position;
            var levelOffset = nextPart.LevelStartPoint.position;

            gameObject.transform.position = levelOffset + ownOffset;
        }
        private LevelPart GeneratePart(LevelPart previousPart)
        {
            var part = _currentLevelIndex < _config.TutorialParts.Length ?
                       GenerateTutorialPart() :
                       GenerateRandomPart();

            Debug.LogWarning($"Set position for {part.name} with previous: {previousPart}");
            part.SetPositionAsNext(previousPart);

            _parts.Add(part);

            _currentLevelIndex++;

            return(part);
        }