예제 #1
0
        public static OsuSpinner Parse(Beatmap beatmap, string[] values, int x, int y, double startTime, HitObjectFlag flags, HitSoundAddition additions, ControlPoint timingPoint, ControlPoint controlPoint, SampleSet sampleSet, SampleSet additionsSampleSet, int customSampleSet, float volume)
        {
            var endTime = double.Parse(values[5], CultureInfo.InvariantCulture);

            string samplePath = string.Empty;

            if (values.Length > 6)
            {
                var special                  = values[6];
                var specialValues            = special.Split(':');
                var objectSampleSet          = (SampleSet)int.Parse(specialValues[0]);
                var objectAdditionsSampleSet = (SampleSet)int.Parse(specialValues[1]);
                var objectCustomSampleSet    = 0;
                if (specialValues.Length > 2)
                {
                    objectCustomSampleSet = int.Parse(specialValues[2]);
                }
                var objectVolume = 0.0f;
                if (specialValues.Length > 3)
                {
                    objectVolume = int.Parse(specialValues[3]);
                }
                if (specialValues.Length > 4)
                {
                    samplePath = specialValues[4];
                }

                if (objectSampleSet != 0)
                {
                    sampleSet          = objectSampleSet;
                    additionsSampleSet = objectSampleSet;
                }
                if (objectAdditionsSampleSet != 0)
                {
                    additionsSampleSet = objectAdditionsSampleSet;
                }
                if (objectCustomSampleSet != 0)
                {
                    customSampleSet = objectCustomSampleSet;
                }
                if (objectVolume > 0.001f)
                {
                    volume = objectVolume;
                }
            }
            return(new OsuSpinner()
            {
                PlayfieldPosition = new Vector2(x, y),
                StartTime = startTime,
                Flags = flags,
                Additions = additions,
                SampleSet = sampleSet,
                AdditionsSampleSet = additionsSampleSet,
                CustomSampleSet = customSampleSet,
                Volume = volume,
                SamplePath = samplePath,
                // Spinner specific
                endTime = endTime,
            });
        }
예제 #2
0
        public static OsuSlider Parse(Beatmap beatmap, string[] values, int x, int y, double startTime, HitObjectFlag flags, HitSoundAddition additions, ControlPoint timingPoint, ControlPoint controlPoint, SampleSet sampleSet, SampleSet additionsSampleSet, int customSampleSet, float volume)
        {
            var slider       = values[5];
            var sliderValues = slider.Split('|');

            var curveType = LetterToCurveType(sliderValues[0]);
            var sliderControlPointCount = sliderValues.Length - 1;
            var sliderControlPoints     = new List <OsuSliderControlPoint>(sliderControlPointCount);

            for (var i = 0; i < sliderControlPointCount; i++)
            {
                var controlPointValues = sliderValues[i + 1].Split(':');
                var controlPointX      = float.Parse(controlPointValues[0], CultureInfo.InvariantCulture);
                var controlPointY      = float.Parse(controlPointValues[1], CultureInfo.InvariantCulture);
                sliderControlPoints.Add(new Vector2(controlPointX, controlPointY));
            }

            var nodeCount = int.Parse(values[6]) + 1;
            var length    = double.Parse(values[7], CultureInfo.InvariantCulture);

            var sliderMultiplierLessLength = length / beatmap.SliderMultiplier;
            var travelDurationBeats        = sliderMultiplierLessLength / 100 * controlPoint.SliderMultiplier;
            var travelDuration             = timingPoint.BeatDuration * travelDurationBeats;

            var sliderNodes = new List <OsuSliderNode>(nodeCount);

            for (var i = 0; i < nodeCount; i++)
            {
                var nodeStartTime    = startTime + i * travelDuration;
                var nodeControlPoint = beatmap.GetTimingPointAt((int)nodeStartTime);
                sliderNodes.Add(new OsuSliderNode()
                {
                    Time               = nodeStartTime,
                    SampleSet          = nodeControlPoint.SampleSet,
                    AdditionsSampleSet = nodeControlPoint.SampleSet,
                    CustomSampleSet    = nodeControlPoint.CustomSampleSet,
                    Volume             = nodeControlPoint.Volume,
                    Additions          = additions,
                });
            }
            if (values.Length > 8)
            {
                var sliderAddition       = values[8];
                var sliderAdditionValues = sliderAddition.Split('|');
                for (var i = 0; i < sliderAdditionValues.Length; i++)
                {
                    var node          = sliderNodes[i];
                    var nodeAdditions = (HitSoundAddition)int.Parse(sliderAdditionValues[i]);
                    node.Additions = nodeAdditions;
                }
            }
            if (values.Length > 9)
            {
                var sampleAndAdditionSampleSet       = values[9];
                var sampleAndAdditionSampleSetValues = sampleAndAdditionSampleSet.Split('|');
                for (var i = 0; i < sampleAndAdditionSampleSetValues.Length; i++)
                {
                    var node = sliderNodes[i];
                    var sampleAndAdditionSampleSetValues2 = sampleAndAdditionSampleSetValues[i].Split(':');
                    var nodeSampleSet          = (SampleSet)int.Parse(sampleAndAdditionSampleSetValues2[0]);
                    var nodeAdditionsSampleSet = (SampleSet)int.Parse(sampleAndAdditionSampleSetValues2[1]);

                    if (nodeSampleSet != 0)
                    {
                        node.SampleSet          = nodeSampleSet;
                        node.AdditionsSampleSet = nodeSampleSet;
                    }
                    if (nodeAdditionsSampleSet != 0)
                    {
                        node.AdditionsSampleSet = nodeAdditionsSampleSet;
                    }
                }
            }

            string samplePath = string.Empty;

            if (values.Length > 10)
            {
                var special                  = values[10];
                var specialValues            = special.Split(':');
                var objectSampleSet          = (SampleSet)int.Parse(specialValues[0]);
                var objectAdditionsSampleSet = (SampleSet)int.Parse(specialValues[1]);
                var objectCustomSampleSet    = int.Parse(specialValues[2]);
                var objectVolume             = 0.0f;
                if (specialValues.Length > 3)
                {
                    objectVolume = int.Parse(specialValues[3]);
                }
                if (specialValues.Length > 4)
                {
                    samplePath = specialValues[4];
                }

                if (objectSampleSet != 0)
                {
                    sampleSet          = objectSampleSet;
                    additionsSampleSet = objectSampleSet;
                }
                if (objectAdditionsSampleSet != 0)
                {
                    additionsSampleSet = objectAdditionsSampleSet;
                }
                if (objectCustomSampleSet != 0)
                {
                    customSampleSet = objectCustomSampleSet;
                }
                if (objectVolume > 0.001f)
                {
                    volume = objectVolume;
                }
            }

            return(new OsuSlider(sliderNodes, sliderControlPoints)
            {
                PlayfieldPosition = new Vector2(x, y),
                StartTime = startTime,
                Flags = flags,
                Additions = additions,
                SampleSet = sampleSet,
                AdditionsSampleSet = additionsSampleSet,
                CustomSampleSet = customSampleSet,
                Volume = volume,
                SamplePath = samplePath,
                // Slider specific
                CurveType = curveType,
                Length = length,
                TravelDurationBeats = travelDurationBeats,
                TravelDuration = travelDuration,
            });
        }
예제 #3
0
        public static OsuCircle Parse(Beatmap beatmap, string[] values, int x, int y, double startTime, HitObjectFlag flags, HitSoundAddition additions, ControlPoint timingPoint, ControlPoint controlPoint, int sampleType, int sampleAdditionsType, SampleSet sampleSet, float volume)
        {
            string samplePath = string.Empty;

            if (values.Length > 5)
            {
                var special                   = values[5];
                var specialValues             = special.Split(':');
                var objectSampleType          = int.Parse(specialValues[0]);
                var objectSampleAdditionsType = int.Parse(specialValues[1]);
                var objectSampleSet           = (SampleSet)int.Parse(specialValues[2]);
                var objectVolume              = 0.0f;
                if (specialValues.Length > 3)
                {
                    objectVolume = int.Parse(specialValues[3]);
                }
                if (specialValues.Length > 4)
                {
                    samplePath = specialValues[4];
                }

                if (objectSampleType != 0)
                {
                    sampleType          = objectSampleType;
                    sampleAdditionsType = objectSampleType;
                }
                if (objectSampleAdditionsType != 0)
                {
                    sampleAdditionsType = objectSampleAdditionsType;
                }
                if (objectSampleSet != 0)
                {
                    sampleSet = objectSampleSet;
                }
                if (objectVolume > 0.001f)
                {
                    volume = objectVolume;
                }
            }
            return(new OsuCircle()
            {
                PlayfieldPosition = new Vector2(x, y),
                StartTime = startTime,
                Flags = flags,
                Additions = additions,
                SampleType = sampleType,
                SampleAdditionsType = sampleAdditionsType,
                SampleSet = sampleSet,
                Volume = volume,
                SamplePath = samplePath,
                // Circle specific
            });
        }