Esempio n. 1
0
        //BeatmapManager and slider
        public void BeatmapManager()
        {
            //this class supplies functions for the hitobjects, difficulty ...
            //the constructor will automatically calculate combocolors, combonumbers and difficulties (such as approachrate ms and timing300)
            var beatmapManager = new BeatmapManager(beatmap);
            var timing300      = beatmapManager.HitWindow300;
            var approachratems = beatmapManager.PreEmpt;

            beatmapManager.SetMods(Mods.HardRock | Mods.Hidden); //enables the mods hardrock and hidden
            beatmapManager.DifficultyCalculations();             //recalculate the difficulties
            var timing300Hr = beatmapManager.HitWindow300;       //this will now be different than the previous timing300

            beatmapManager.SliderCalculations();
            //this will create curves for the sliders. As this is an intensive task, it's async -> wait
            //this will get the selected map's hitobjects (better to work this way, no need for a reference to the beatmap)
            var hitobjects = beatmapManager.GetHitObjects();
            //some LINQ to select the first slider in the list
            var firstslider    = (Slider)hitobjects.First(ho => ho.IsHitObjectType(HitObjectType.Slider));
            var positionAt20Ms = firstslider.PositionAtTime(firstslider.StartTime + 20);
        }
Esempio n. 2
0
 public void SetManager(BeatmapManager manager)
 {
     _modSpeed    = manager.ModSpeedMultiplier;
     TpHitObjects = manager.GetHitObjects().Select(ho => new TpHitObject(ho, manager.HitObjectRadius));//.ToList();
 }
Esempio n. 3
0
        public static string Convert(string filename, List <string> lines, double bpm)
        {
            _r = null;

            int noteId    = 1;
            var msPerBeat = 60000 / bpm;
            var sb        = new StringBuilder();
            var bm        = new Beatmap(filename);

            bm.Bpm = bpm;
            bm.ReadFile();

            var bmm = new BeatmapManager(bm);

            bmm.SliderCalculations();

            var lastType = 0;
            var lastTime = 0;
            var lastPos  = -1;

            var inHitObjects = false;

            foreach (var line in lines)
            {
                if (!inHitObjects)
                {
                    if (line == "[HitObjects]")
                    {
                        inHitObjects = true;
                    }
                    continue;
                }

                var arr      = line.Split('|');
                var basicarr = arr[0].Split(',');

                // seed random with bm-specific values
                if (_r == null)
                {
                    // seed = x ^ y ^ time
                    _r = new Random(
                        Int32.Parse(basicarr[0]) ^
                        Int32.Parse(basicarr[1]) ^
                        Int32.Parse(basicarr[2]));
                }

                var hitobjs = bmm.GetHitObjects();
                var type    = Int32.Parse(basicarr[3]);
                var bmTime  = Int32.Parse(basicarr[2]);
                var time    = Helpers.TimeToBeats(bmTime, bpm);

                if ((type & 2) > 0)
                {
                    var slider = hitobjs.FirstOrDefault(o => o.StartTime == bmTime) as Slider;
                    ParseSlider(slider, arr, basicarr, sb, bpm, ref noteId);
                    lastType = 1;
                }
                else if ((type & 8) > 0)
                {
                    // spinner

                    var end = Helpers.TimeToBeats(Int32.Parse(basicarr[5]), bpm);
                    sb.AppendLine($"{noteId},1,2,2,0,{time.Item1},{time.Item2},0,{end.Item1},{end.Item2},0");
                    ++noteId;
                    _lastSliderEnd = -1;
                    lastType       = 2;
                }
                else
                {
                    // note
                    // TODO: handle in groups
                    var startPos     = Int32.Parse(basicarr[0]) / 103;
                    var endPos       = Int32.Parse(basicarr[1]) / 77;
                    var actualEndPos = endPos;
                    if (lastType == 3 && (bmTime - lastTime) < msPerBeat / 3)
                    {
                        if (lastPos == endPos)
                        {
                            if (_currGroupOtherPos < 0 || _currGroupOtherPos == endPos)
                            {
                                _currGroupOtherPos = _r.Next(0, 4);
                                if (_currGroupOtherPos >= endPos)
                                {
                                    ++_currGroupOtherPos;
                                }
                            }
                            actualEndPos = _currGroupOtherPos;
                        }
                    }
                    else
                    {
                        _currGroupOtherPos = -1;
                    }

                    sb.AppendLine($"{noteId},0,{startPos},{actualEndPos},0,{time.Item1},{time.Item2},0");
                    ++noteId;

                    lastPos        = actualEndPos;
                    _lastSliderEnd = -1;
                    lastType       = 3;
                }

                lastTime = bmTime;
            }

            return(sb.ToString());
        }