Exemplo n.º 1
0
        private AnimatedBackgroundSegment[] CreateSegments()
        {
            float maximumCameraY       = _worldDimensions.Y - Definitions.Back_Buffer_Height;
            float allowedVerticalRange = MathHelper.Min(maximumCameraY * Vertical_Range_Modifier, Maximum_Vertical_Range);
            float horizontalRange      = Wrap ? _worldDimensions.X * 0.5f : _worldDimensions.X * 0.8f;

            _maximumY         = allowedVerticalRange;
            _verticalModifier = maximumCameraY == 0.0f ? 0.0f : allowedVerticalRange / maximumCameraY;

            string segmentTexture = _texture + "-segments";
            float  nextSegmentX   = 0.0f;
            List <AnimatedBackgroundSegment> segments = new List <AnimatedBackgroundSegment>();

            while (nextSegmentX < horizontalRange)
            {
                int nextSegmentIndex = NextGeneratorValue();
                if ((ComponentSequence != null) && (ComponentSequence.Length > 0))
                {
                    nextSegmentIndex      = ComponentSequence[_segmentSequenceIndex];
                    _segmentSequenceIndex = (_segmentSequenceIndex + 1) % ComponentSequence.Length;
                }

                AnimatedBackgroundSegment segment = new AnimatedBackgroundSegment(segmentTexture, segments.Count, nextSegmentIndex, NextGeneratorValue());
                segments.Add(segment);
                nextSegmentX += AnimatedBackgroundSegment.SegmentWidth(segmentTexture) + (NextGeneratorValue() * Segment_Spacing_Modifier);
            }

            return(segments.ToArray());
        }
        private AnimatedBackgroundSegment[] CreateSegments()
        {
            float maximumCameraY = _worldDimensions.Y - Definitions.Back_Buffer_Height;
            float allowedVerticalRange = MathHelper.Min(maximumCameraY * Vertical_Range_Modifier, Maximum_Vertical_Range);
            float horizontalRange = Wrap ? _worldDimensions.X * 0.5f : _worldDimensions.X * 0.8f;

            _maximumY = allowedVerticalRange;
            _verticalModifier = maximumCameraY == 0.0f ? 0.0f : allowedVerticalRange / maximumCameraY;

            string segmentTexture = _texture + "-segments";
            float nextSegmentX = 0.0f;
            List<AnimatedBackgroundSegment> segments = new List<AnimatedBackgroundSegment>();

            while (nextSegmentX < horizontalRange)
            {
                int nextSegmentIndex = NextGeneratorValue();
                if ((ComponentSequence != null) && (ComponentSequence.Length > 0))
                {
                    nextSegmentIndex = ComponentSequence[_segmentSequenceIndex];
                    _segmentSequenceIndex = (_segmentSequenceIndex + 1) % ComponentSequence.Length;
                }

                AnimatedBackgroundSegment segment = new AnimatedBackgroundSegment(segmentTexture, segments.Count, nextSegmentIndex, NextGeneratorValue());
                segments.Add(segment);
                nextSegmentX += AnimatedBackgroundSegment.SegmentWidth(segmentTexture) + (NextGeneratorValue() * Segment_Spacing_Modifier);
            }

            return segments.ToArray();
        }