示例#1
0
        public HitObjectPatternGenerator(LegacyRandom random, HitObject hitObject, ManiaBeatmap beatmap, Pattern previousPattern, double previousTime, Vector2 previousPosition, double density,
                                         PatternType lastStair, IBeatmap originalBeatmap)
            : base(random, hitObject, beatmap, previousPattern, originalBeatmap)
        {
            StairType = lastStair;

            TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime);
            EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(hitObject.StartTime);

            var positionData = hitObject as IHasPosition;

            float  positionSeparation = ((positionData?.Position ?? Vector2.Zero) - previousPosition).Length;
            double timeSeparation     = hitObject.StartTime - previousTime;

            if (timeSeparation <= 80)
            {
                // More than 187 BPM
                convertType |= PatternType.ForceNotStack | PatternType.KeepSingle;
            }
            else if (timeSeparation <= 95)
            {
                // More than 157 BPM
                convertType |= PatternType.ForceNotStack | PatternType.KeepSingle | lastStair;
            }
            else if (timeSeparation <= 105)
            {
                // More than 140 BPM
                convertType |= PatternType.ForceNotStack | PatternType.LowProbability;
            }
            else if (timeSeparation <= 125)
            {
                // More than 120 BPM
                convertType |= PatternType.ForceNotStack;
            }
            else if (timeSeparation <= 135 && positionSeparation < 20)
            {
                // More than 111 BPM stream
                convertType |= PatternType.Cycle | PatternType.KeepSingle;
            }
            else if (timeSeparation <= 150 && positionSeparation < 20)
            {
                // More than 100 BPM stream
                convertType |= PatternType.ForceStack | PatternType.LowProbability;
            }
            else if (positionSeparation < 20 && density >= timingPoint.BeatLength / 2.5)
            {
                // Low density stream
                convertType |= PatternType.Reverse | PatternType.LowProbability;
            }
            else if (density < timingPoint.BeatLength / 2.5 || effectPoint.KiaiMode)
            {
                // High density
            }
            else
            {
                convertType |= PatternType.LowProbability;
            }

            if (!convertType.HasFlagFast(PatternType.KeepSingle))
            {
                if (HitObject.Samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH) && TotalColumns != 8)
                {
                    convertType |= PatternType.Mirror;
                }
                else if (HitObject.Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP))
                {
                    convertType |= PatternType.Gathered;
                }
            }
        }
        private Pattern generate()
        {
            if (TotalColumns == 1)
            {
                var pattern = new Pattern();
                addToPattern(pattern, 0, StartTime, EndTime);
                return(pattern);
            }

            if (SpanCount > 1)
            {
                if (SegmentDuration <= 90)
                {
                    return(generateRandomHoldNotes(StartTime, 1));
                }

                if (SegmentDuration <= 120)
                {
                    convertType |= PatternType.ForceNotStack;
                    return(generateRandomNotes(StartTime, SpanCount + 1));
                }

                if (SegmentDuration <= 160)
                {
                    return(generateStair(StartTime));
                }

                if (SegmentDuration <= 200 && ConversionDifficulty > 3)
                {
                    return(generateRandomMultipleNotes(StartTime));
                }

                double duration = EndTime - StartTime;
                if (duration >= 4000)
                {
                    return(generateNRandomNotes(StartTime, 0.23, 0, 0));
                }

                if (SegmentDuration > 400 && SpanCount < TotalColumns - 1 - RandomStart)
                {
                    return(generateTiledHoldNotes(StartTime));
                }

                return(generateHoldAndNormalNotes(StartTime));
            }

            if (SegmentDuration <= 110)
            {
                if (PreviousPattern.ColumnWithObjects < TotalColumns)
                {
                    convertType |= PatternType.ForceNotStack;
                }
                else
                {
                    convertType &= ~PatternType.ForceNotStack;
                }
                return(generateRandomNotes(StartTime, SegmentDuration < 80 ? 1 : 2));
            }

            if (ConversionDifficulty > 6.5)
            {
                if (convertType.HasFlagFast(PatternType.LowProbability))
                {
                    return(generateNRandomNotes(StartTime, 0.78, 0.3, 0));
                }

                return(generateNRandomNotes(StartTime, 0.85, 0.36, 0.03));
            }

            if (ConversionDifficulty > 4)
            {
                if (convertType.HasFlagFast(PatternType.LowProbability))
                {
                    return(generateNRandomNotes(StartTime, 0.43, 0.08, 0));
                }

                return(generateNRandomNotes(StartTime, 0.56, 0.18, 0));
            }

            if (ConversionDifficulty > 2.5)
            {
                if (convertType.HasFlagFast(PatternType.LowProbability))
                {
                    return(generateNRandomNotes(StartTime, 0.3, 0, 0));
                }

                return(generateNRandomNotes(StartTime, 0.37, 0.08, 0));
            }

            if (convertType.HasFlagFast(PatternType.LowProbability))
            {
                return(generateNRandomNotes(StartTime, 0.17, 0, 0));
            }

            return(generateNRandomNotes(StartTime, 0.27, 0, 0));
        }