예제 #1
0
        /// <summary>
        ///     从bestdori谱面文本构造谱面对象
        /// </summary>
        /// <param name="scoreString">谱面文本</param>
        public DefaultScore GetDefaultScoreFromBestdoriScore(string scoreString)
        {
            var defaultScore = new DefaultScore();
            var arrayList    = JsonConvert.DeserializeObject <ArrayList>(scoreString);
            var head         = new Head
            {
                bpm  = ((JObject)arrayList[0])["bpm"].ToObject <float>(),
                beat = ((JObject)arrayList[0])["beat"].ToObject <double>()
            };

            defaultScore.Bpm      = head.bpm;
            defaultScore.Delay_ms = (int)(head.beat / head.bpm * 60000);

            //提取note列表
            arrayList.RemoveAt(0);
            var tempJson = JsonConvert.SerializeObject(arrayList);
            var tempList = JsonConvert.DeserializeObject <List <DataClass.Bestdori.Note> >(tempJson);

            var notes = new List <Note>();

            foreach (var note in tempList)
            {
                var tempNote = new Note {
                    Time = note.beat + _delay, Track = note.lane
                };

                if (note.note == DataClass.Bestdori.NoteType.Single &&
                    !note.skill &&
                    !note.flick)
                {
                    tempNote.NoteType = NoteType.白键;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Single &&
                    note.skill &&
                    !note.flick)
                {
                    tempNote.NoteType = NoteType.技能;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Single &&
                    !note.skill &&
                    note.flick)
                {
                    tempNote.NoteType = NoteType.粉键;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Slide &&
                    note.pos == PosType.A &&
                    note.start &&
                    !note.end &&
                    !note.flick)
                {
                    tempNote.NoteType = NoteType.滑条a_开始;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Slide &&
                    note.pos == PosType.A &&
                    !note.start &&
                    !note.end &&
                    !note.flick)
                {
                    tempNote.NoteType = NoteType.滑条a_中间;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Slide &&
                    note.pos == PosType.A &&
                    !note.start &&
                    note.end &&
                    !note.flick)
                {
                    tempNote.NoteType = NoteType.滑条a_结束;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Slide &&
                    note.pos == PosType.A &&
                    !note.start &&
                    note.end &&
                    note.flick)
                {
                    tempNote.NoteType = NoteType.滑条a_粉键结束;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Slide &&
                    note.pos == PosType.B &&
                    note.start &&
                    !note.end &&
                    !note.flick)
                {
                    tempNote.NoteType = NoteType.滑条b_开始;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Slide &&
                    note.pos == PosType.B &&
                    !note.start &&
                    !note.end &&
                    !note.flick)
                {
                    tempNote.NoteType = NoteType.滑条b_中间;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Slide &&
                    note.pos == PosType.B &&
                    !note.start &&
                    note.end &&
                    !note.flick)
                {
                    tempNote.NoteType = NoteType.滑条b_结束;
                    notes.Add(tempNote);
                    continue;
                }

                if (note.note == DataClass.Bestdori.NoteType.Slide &&
                    note.pos == PosType.B &&
                    !note.start &&
                    note.end &&
                    note.flick)
                {
                    tempNote.NoteType = NoteType.滑条b_粉键结束;
                    notes.Add(tempNote);
                    continue;
                }

                throw new Exception("bestdori=>bangSimulator音符转换失败");
            }

            //先按时间排,然后按轨道从左到右排
            defaultScore.Notes = notes.OrderBy(p => p.Time).ThenBy(p => p.Track).ToList();
            return(defaultScore);
        }
예제 #2
0
        /// <summary>
        ///     从bandori database谱面json构造谱面对象
        /// </summary>
        /// <param name="scoreString">谱面文本</param>
        public DefaultScore GetDefaultScoreFromBandoriJson(string scoreString)
        {
            var defaultScore = new DefaultScore();
            var score        = JsonConvert.DeserializeObject <dynamic>(scoreString);

            defaultScore.Bpm      = score.metadata.bpm;
            defaultScore.Delay_ms = 0;
            var noteList = new List <Note>();

            foreach (var note in score.objects)
            {
                if (note.type == "System")
                {
                    continue;
                }
                var defaultNote = new Note
                {
                    Time  = note.beat + _delay,
                    Track = note.lane
                };

                if ((note.effect == "Single" || note.effect == "FeverSingle") && note.property == "Single")
                {
                    defaultNote.NoteType = NoteType.白键;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "Skill" && note.property == "Single")
                {
                    defaultNote.NoteType = NoteType.技能;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "Flick" && note.property == "Single")
                {
                    defaultNote.NoteType = NoteType.粉键;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "SlideStart_A" && note.property == "Slide")
                {
                    defaultNote.NoteType = NoteType.滑条a_开始;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "Slide_A" && note.property == "Slide")
                {
                    defaultNote.NoteType = NoteType.滑条a_中间;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "SlideEnd_A" && note.property == "Slide")
                {
                    defaultNote.NoteType = NoteType.滑条a_结束;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "SlideEndFlick_A" && note.property == "Slide")
                {
                    defaultNote.NoteType = NoteType.滑条a_粉键结束;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "SlideStart_B" && note.property == "Slide")
                {
                    defaultNote.NoteType = NoteType.滑条b_开始;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "Slide_B" && note.property == "Slide")
                {
                    defaultNote.NoteType = NoteType.滑条b_中间;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "SlideEnd_B" && note.property == "Slide")
                {
                    defaultNote.NoteType = NoteType.滑条b_结束;
                    noteList.Add(defaultNote);
                    continue;
                }

                if ((note.effect == "Single" || note.effect == "Skill" || note.effect == "FeverSingle") &&
                    note.property == "LongStart")
                {
                    defaultNote.NoteType = NoteType.长键_开始;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "Single" && note.property == "LongEnd")
                {
                    defaultNote.NoteType = NoteType.长键_结束;
                    noteList.Add(defaultNote);
                    continue;
                }

                if (note.effect == "Flick" && note.property == "LongEnd")
                {
                    defaultNote.NoteType = NoteType.长键_粉键结束;
                    noteList.Add(defaultNote);
                }
            }

            defaultScore.Notes = noteList;

            return(defaultScore);
        }