Exemple #1
0
 protected HitObject(int startTime, Position position, bool isNewcombo, HitObjectType type, HitObjectSoundType soundType)
 {
     StartTime     = startTime;
     StartPosition = position;
     NewCombo      = isNewcombo || type.HasFlag(HitObjectType.NewCombo)
         ? 1 + ((int)(type & HitObjectType.CustomCombo) >> 4)
         : 0;
     Type      = type ^ (type & (HitObjectType.CustomCombo | HitObjectType.NewCombo)); //take out new combo bits (64, 32, 16 and 4)
     SoundType = soundType;
 }
Exemple #2
0
        private HitObject[] parseHitObjects()
        {
            String[]         RawObjects    = getContent("HitObjects");
            List <HitObject> ParsedObjects = new List <HitObject>();

            foreach (String RawObject in RawObjects)
            {
                String[] Parameters = RawObject.Split(',');

                HitObject     Object = new HitObject();
                HitObjectType Type   = (HitObjectType)Int32.Parse(Parameters[3]);
                ColorIndex += (Type.HasFlag(HitObjectType.SkipColor3) ? 4 : 0) + (Type.HasFlag(HitObjectType.SkipColor2) ? 2 : 0) + (Type.HasFlag(HitObjectType.SkipColor1) ? 1 : 0) + (Type.HasFlag(HitObjectType.NewCombo) ? 1 : 0);
                Vector2 Vector = new Vector2(Int32.Parse(Parameters[0]) + 64, Int32.Parse(Parameters[1]) + 56);

                if (Type.HasFlag(HitObjectType.Circle))
                {
                    Object = new Circle(Type, Vector, Int32.Parse(Parameters[2]), Colors[ColorIndex % Colors.Length]);
                }
                else if (Type.HasFlag(HitObjectType.Slider))
                {
                    List <String> SliderParameters = new List <String>();
                    for (int i = 5; i < Parameters.Length; i++)
                    {
                        SliderParameters.Add(Parameters[i]);
                    }
                    int Time = Int32.Parse(Parameters[2]);
                    Object = new Slider(Type, Vector, Time, Colors[ColorIndex % Colors.Length], new double[] { getBPMAt(Time), getSliderVelocityAt(Time) }, SliderParameters.ToArray());
                }
                else if (Type.HasFlag(HitObjectType.Spinner))
                {
                    Object = new Spinner(Type, Vector, Int32.Parse(Parameters[2]), new Color(255, 255, 255), Int32.Parse(Parameters[5]));
                }

                ParsedObjects.Add(Object);
            }
            return(ParsedObjects.ToArray());
        }
        private void ParseHitObjects(string line)
        {
            string[] tokens = line.Split(',');

            Point position = new Point(Convert.ToInt32(tokens[0]), Convert.ToInt32(tokens[1]));

            int startTime = Convert.ToInt32(tokens[2]);

            HitObjectType type = (HitObjectType)int.Parse(tokens[3]);

            int comboOffset = (int)(type & HitObjectType.ComboOffset) >> 4;

            type &= ~HitObjectType.ComboOffset;

            bool isNewCombo = type.HasFlag(HitObjectType.NewCombo);

            type &= ~HitObjectType.NewCombo;

            HitSoundType hitSound = (HitSoundType)Convert.ToInt32(tokens[4]);

            HitObject hitObject = null;

            string[] extrasSplit  = tokens.Last().Split(':');
            int      extrasOffset = type.HasFlag(HitObjectType.Hold) ? 1 : 0;
            Extras   extras       = tokens.Last().Contains(":") ? new Extras
            {
                SampleSet      = (SampleSet)Convert.ToInt32(extrasSplit[0 + extrasOffset]),
                AdditionSet    = (SampleSet)Convert.ToInt32(extrasSplit[1 + extrasOffset]),
                CustomIndex    = Convert.ToInt32(extrasSplit[2 + extrasOffset]),
                Volume         = Convert.ToInt32(extrasSplit[3 + extrasOffset]),
                SampleFileName = string.IsNullOrEmpty(extrasSplit[4 + extrasOffset]) ? null : extrasSplit[4 + extrasOffset]
            } : new Extras();

            switch (type)
            {
            case HitObjectType.Circle:
            {
                if (Beatmap.GeneralSection.Mode == Ruleset.Standard)
                {
                    hitObject = new Circle(position, startTime, startTime, hitSound, extras, isNewCombo, comboOffset);
                }
                else if (Beatmap.GeneralSection.Mode == Ruleset.Taiko)
                {
                    hitObject = new TaikoHit(position, startTime, startTime, hitSound, extras, isNewCombo, comboOffset);
                }
                else if (Beatmap.GeneralSection.Mode == Ruleset.Fruits)
                {
                    hitObject = new CatchFruit(position, startTime, startTime, hitSound, extras, isNewCombo, comboOffset);
                }
                else if (Beatmap.GeneralSection.Mode == Ruleset.Mania)
                {
                    hitObject = new ManiaHit(position, startTime, startTime, hitSound, extras, isNewCombo, comboOffset);
                }
            }
            break;

            case HitObjectType.Slider:
            {
                CurveType    curveType    = ParseHelper.GetCurveType(tokens[5].Split('|')[0][0]);
                List <Point> sliderPoints = ParseHelper.GetSliderPoints(tokens[5].Split('|'));

                int    repeats     = Convert.ToInt32(tokens[6]);
                double pixelLength = ParseHelper.ToDouble(tokens[7]);

                int endTime = CalculateEndTime(startTime, repeats, pixelLength);

                List <HitSoundType> edgeHitSounds = new List <HitSoundType>();
                if (tokens.Length > 8 && tokens[8].Length > 0)
                {
                    edgeHitSounds = new List <HitSoundType>();
                    edgeHitSounds = Array.ConvertAll(tokens[8].Split('|'), s => (HitSoundType)Convert.ToInt32(s)).ToList();
                }

                List <Tuple <SampleSet, SampleSet> > edgeAdditions = new List <Tuple <SampleSet, SampleSet> >();
                if (tokens.Length > 9 && tokens[9].Length > 0)
                {
                    edgeAdditions = new List <Tuple <SampleSet, SampleSet> >();
                    foreach (var s in tokens[9].Split('|'))
                    {
                        edgeAdditions.Add(new Tuple <SampleSet, SampleSet>((SampleSet)Convert.ToInt32(s.Split(':').First()), (SampleSet)Convert.ToInt32(s.Split(':').Last())));
                    }
                }

                if (Beatmap.GeneralSection.Mode == Ruleset.Standard)
                {
                    hitObject = new Slider(position, startTime, endTime, hitSound, curveType, sliderPoints, repeats,
                                           pixelLength, edgeHitSounds, edgeAdditions, extras, isNewCombo, comboOffset);
                }
                else if (Beatmap.GeneralSection.Mode == Ruleset.Taiko)
                {
                    hitObject = new TaikoDrumroll(position, startTime, endTime, hitSound, curveType, sliderPoints,
                                                  repeats, pixelLength, edgeHitSounds, edgeAdditions, extras, isNewCombo, comboOffset);
                }
                else if (Beatmap.GeneralSection.Mode == Ruleset.Fruits)
                {
                    hitObject = new CatchDroplets(position, startTime, endTime, hitSound, curveType, sliderPoints,
                                                  repeats, pixelLength, edgeHitSounds, edgeAdditions, extras, isNewCombo, comboOffset);
                }
            }
            break;

            case HitObjectType.Spinner:
            {
                int endTime = Convert.ToInt32(tokens[5].Trim());

                if (Beatmap.GeneralSection.Mode == Ruleset.Standard)
                {
                    hitObject = new Spinner(position, startTime, endTime, hitSound, extras, isNewCombo, comboOffset);
                }
                else if (Beatmap.GeneralSection.Mode == Ruleset.Taiko)
                {
                    hitObject = new TaikoSpinner(position, startTime, endTime, hitSound, extras, isNewCombo, comboOffset);
                }
                else if (Beatmap.GeneralSection.Mode == Ruleset.Fruits)
                {
                    hitObject = new CatchSpinner(position, startTime, endTime, hitSound, extras, isNewCombo, comboOffset);
                }
            }
            break;

            case HitObjectType.Hold:
            {
                string[] additions = tokens[5].Split(':');
                int      endTime   = Convert.ToInt32(additions[0].Trim());
                hitObject = new ManiaHold(position, startTime, endTime, hitSound, extras, isNewCombo, comboOffset);
            }
            break;
            }

            Beatmap.HitObjects.Add(hitObject);
        }
 public bool IsType(HitObjectType type)
 {
     return(Type.HasFlag(type));
 }
Exemple #5
0
 public HitObjectType getType() => Type.HasFlag(HitObjectType.Circle) ? HitObjectType.Circle : (Type.HasFlag(HitObjectType.Slider) ? HitObjectType.Slider : HitObjectType.Spinner);