Beispiel #1
0
        private Segment RequestNextSegment()
        {
            var segment = _generator.GenerateNextSegment();

            Map.Enqueue(segment);
            return(segment);
        }
Beispiel #2
0
        private void ExpandMap(Segment segmentInfo)
        {
            var segmentView = TakeSegment();

            var size   = segmentInfo.size;
            var offset = Vector2.zero;

            if (_segments.Count > 0)
            {
                offset = segmentInfo.dir == Direction.FORWARD
                    ? new Vector2(-size.x, size.y)
                    : new Vector2(size.x, -size.y);
            }
            var pos = _lastSegmentPosMap + (_lastSegmentSizeMap + offset) / 2f;

            segmentView.segment.localScale      = SetLocalFromMap(segmentView.segment.localScale, size);
            segmentView.transform.localPosition = SetLocalFromMap(segmentView.transform.localPosition, pos);

            segmentView.bonus.gameObject.SetActive(segmentInfo.hasBonus);
            segmentView.bonus.localPosition = SetLocalFromMap(segmentView.bonus.localPosition, segmentInfo.bonusPos - size / 2f);

            _lastSegmentPosMap   = pos;
            _lastSegmentSizeMap  = size;
            _lastSegmentPosWorld = segmentView.transform.position;

            _segments.Enqueue(segmentView);
        }