Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="line">[00111:00000100]</param>
        private void ParseDataField(string[] arr)
        {
            int[] key = line2key(arr[0]);// 001 00
            List<string> val = line2arr(arr[1]);// 00 01 AW 00
            switch (key[1])
            {
                case 1:  //BGM
                    for (int i = 0; i < val.Count; i++)
                    {
                        if (val[i] == "00")
                            continue;
                        string fn;
                        if (wavDict.TryGetValue(val[i], out fn))
                        {
                            Event e = new Event();
                            e.Section = key[0];
                            e.Filename = fn;
                            e.Offset = 1.0 * i / val.Count;
                            map.EventList.Add(e);
                        }
                    }
                    break;
                case 2:  //beat change
                    {
                        int Section = key[0];
                        int Offset = 0;
                        Timing target = map.TimingList.Find(t => t.Section == Section && t.Offset == Offset);
                        if (target == null)
                        {
                            Timing t = new Timing();
                            t.beat = double.Parse(arr[1]);
                            t.Section = Section;
                            t.Offset = Offset;
                            map.TimingList.Add(t);
                        }else
                            target.beat = double.Parse(arr[1]);
                    }
                    break;
                case 3:   //hardcode bpm
                    for (int i = 0; i < val.Count; i++)
                    {
                        if (val[i] == "00")
                            continue;
                        Timing t = new Timing();
                        t.Section = key[0];
                        t.Offset = 1.0 * i / val.Count;
                        t.bpm = Convert.ToInt32(val[i], 16);
                        t.changed = true;
                        map.TimingList.Add(t);
                    }
                    break;
                case 8:  //pre-defined bpm
                    for (int i = 0; i < val.Count; i++)
                    {
                        if (val[i] == "00")
                            continue;
                        double bpm;
                        if (map.BpmDict.TryGetValue(val[i], out bpm))
                        {
                            Timing t = new Timing();
                            t.Section = key[0];
                            t.Offset = 1.0 * i / val.Count;
                            t.bpm = bpm;
                            t.changed = true;
                            map.TimingList.Add(t);
                        }
                    }
                    break;
                case 11:
                case 12:
                case 13:
                case 14:
                case 15:
                case 16:
                case 18:
                case 19:
                    {
                        for (int i = 0; i < val.Count; i++)
                        {
                            if (val[i] == "00")
                                continue;
                            int col = key[1] == 16 ? 0 : (key[1] < 16 ? key[1] - 10 : key[1] - 12);
                            if (longType == 2 && val[i] == longObj && pendingNote[col] != null)
                            {
                                pendingNote[col].SectionEnd = key[0];
                                pendingNote[col].OffsetEnd = 1.0 * i / val.Count;
                                pendingNote[col].Type = NoteType.ManiaLong;
                                pendingNote[col] = null;
                                continue;
                            }
                            Note n = new Note();
                            n.Column = col;
                            n.SectionStart = key[0];
                            n.OffsetStart = 1.0 * i / val.Count;
                            n.Type = NoteType.Normal;
                            n.Sound = SampleManager.Get(val[i]);
                            map.NoteList.Add(n);
                            if(col>map.Column-1)
                                map.Column = col + 1; //reset map column
                            if (col == 0)
                                map.Special = true;
                            if (longType == 2)
                                pendingNote[col] = n;
                        }
                    }
                    break;
                case 51:
                case 52:
                case 53:
                case 54:
                case 55:
                case 56:
                case 58:
                case 59:
                    {
                        if (longType != 1)
                            break;
                        for (int i = 0; i < val.Count; i++)
                        {
                            if (val[i] == "00")
                                continue;
                            int col = key[1] == 56 ? 0 : (key[1] < 56 ? key[1] - 50 : key[1] - 52);
                            if (pendingNote[col] != null)
                            {
                                pendingNote[col].SectionEnd = key[0];
                                pendingNote[col].OffsetEnd = 1.0 * i / val.Count;
                                pendingNote[col] = null;
                                continue;
                            }
                            else
                            {
                                Note n = new Note();
                                n.Column = col;
                                n.SectionStart = key[0];
                                n.OffsetStart = 1.0 * i / val.Count;
                                n.Type = NoteType.ManiaLong;
                                n.Sound = SampleManager.Get(val[i]);
                                map.NoteList.Add(n);
                                if (col > map.Column - 1)
                                    map.Column = col + 1; //reset map column
                                if (col == 0)
                                    map.Special = true;
                                pendingNote[col] = n;
                            }

                        }
                    }
                    break;
            }
        }
Exemplo n.º 2
0
 private double getEventTime(Event e)
 {
     Timing t = new Timing();
     t.Section = e.Section;
     t.Offset = e.Offset;
     int index = TimingList.BinarySearch(t);
     if (index < 0)
         index = ~index;
     if (index > TimingList.Count)
         index = TimingList.Count;
     Timing target = TimingList[index==0?0:index - 1];
     return ((t.Section + t.Offset) - (target.Section + target.Offset)) * (60000 * 4 / target.bpm) * target.beat + target.Time;
 }