Exemple #1
0
        public static VoezBeatmapData SMap_to_VMap(Beatmap sMap)
        {
            if (sMap is null)
            {
                return(null);
            }
            sMap.SortNotesByTime();
            int noteLen  = sMap.Notes.Count;
            int trackLen = sMap.Tracks.Count;
            var vMap     = new VoezBeatmapData()
            {
                m_Notes  = new VoezNoteData[noteLen],
                m_Tracks = new VoezTrackData[trackLen],
            };

            // Notes
            for (int i = 0; i < noteLen; i++)
            {
                var note = sMap.Notes[i];
                var type = GetNoteType(note);
                vMap.m_Notes[i] = new VoezNoteData()
                {
                    Id    = i,
                    Track = note.TrackIndex,
                    Type  = GetVoezNoteType(type),
                    Dir   = type == NoteType.SwipeRight ? 1 : 0,
                    Hold  = type == NoteType.Hold ? note.Duration : 0f,
                    Time  = note.Time,
                };
            }
            // Tracks
            for (int i = 0; i < trackLen; i++)
            {
                var sTrack = sMap.Tracks[i];
                for (int j = 0; j < sTrack.Colors.Count; j++)
                {
                    var value = sTrack.Colors[j];
                    value.Value      = (byte)Mathf.Clamp(sTrack.Colors[j].Value, 0, 10);
                    sTrack.Colors[j] = value;
                }
                vMap.m_Tracks[i] = new VoezTrackData()
                {
                    Id    = i,
                    Start = sTrack.Time,
                    End   = Mathf.Max(Mathf.Max(
                                          sTrack.Colors.Count > 0 ? sTrack.Colors[sTrack.Colors.Count - 1].Time : 0,
                                          sTrack.Xs.Count > 0 ? sTrack.Xs[sTrack.Xs.Count - 1].Time : 0),
                                      sTrack.Widths.Count > 0 ? sTrack.Widths[sTrack.Widths.Count - 1].Time : 0
                                      ) + sTrack.Time,
                    X            = Mathf.Clamp01(Util.Remap(0f, 1f, 0f, 1f, sTrack.X)),
                    Size         = sTrack.Width,
                    Color        = sTrack.Color,
                    Move         = GetVoezMovementArray(sTrack.Xs, sTrack.X, sTrack.Time, 0f, 1f),
                    Scale        = GetVoezMovementArray(sTrack.Widths, 0f, sTrack.Time, 0f, 10f),
                    ColorChange  = GetVoezMovementArray(sTrack.Colors, 0, sTrack.Time, 0f, 1f),
                    EntranceOn   = true,
                    PositionLock = false,
                };
            }
            return(vMap);
        }
Exemple #2
0
        public static Beatmap VMap_to_SMap(VoezBeatmapData vMap)
        {
            if (vMap is null)
            {
                return(null);
            }
            var data = new Beatmap {
                BPM         = 120,
                Shift       = 0f,
                Level       = 1,
                Ratio       = 1.5f,
                Tag         = "Normal",
                CreatedTime = System.DateTime.Now.Ticks,
                Timings     = new List <Beatmap.Timing>(),
                Stages      = new List <Beatmap.Stage> {
                    new Beatmap.Stage()                       // Bottom
                    {
                        Duration  = float.MaxValue,
                        Rotation  = 0f,
                        Speed     = 1f,
                        Time      = 0f,
                        Width     = 0.8f,
                        Height    = 2f / 3f,
                        X         = 0.5f,
                        Y         = 0f,
                        Heights   = { },
                        Widths    = { },
                        Positions = { },
                        Rotations = { },
                    }
                },
                Tracks = new List <Beatmap.Track>(),
                Notes  = new List <Beatmap.Note>(),
            };

            // Notes
            for (int i = 0; i < vMap.m_Notes.Length; i++)
            {
                var vNote = vMap.m_Notes[i];
                var type  = GetNoteType(vNote.Type, vNote.Dir);
                data.Notes.Add(new Beatmap.Note()
                {
                    TrackIndex      = vNote.Track,
                    Time            = vNote.Time,
                    Duration        = type == NoteType.Hold ? vNote.Hold : 0f,
                    X               = 0.5f,
                    Width           = 1f,
                    LinkedNoteIndex = -1,
                    ClickSoundIndex = 0,
                    ItemType        = (int)type,
                    Speed           = 1f,
                });
            }

            // Tracks
            for (int i = 0; i < vMap.m_Tracks.Length; i++)
            {
                data.Tracks.Add(new Beatmap.Track());
            }
            for (int i = 0; i < vMap.m_Tracks.Length; i++)
            {
                var vTrack = vMap.m_Tracks[i];
                int id     = vTrack.Id;
                if (id < 0 || id >= data.Tracks.Count)
                {
                    continue;
                }
                data.Tracks[id] = new Beatmap.Track()
                {
                    Time     = vTrack.Start,
                    X        = vTrack.X,
                    Duration = vTrack.End - vTrack.Start,
                    Width    = vTrack.Size * 0.1f,
                    Color    = (byte)vTrack.Color,
                    Angle    = 0f,
                    Xs       = GetMovementArrayFromVoezData(
                        vTrack.Move, vTrack.End, -vTrack.X,
                        -vTrack.Start, 0f,
                        0f, 1f
                        ),
                    Widths = GetMovementArrayFromVoezData(
                        vTrack.Scale, vTrack.End, 0f,
                        -vTrack.Start, vTrack.Size,
                        0f, 1f
                        ),
                    Colors = GetColorArrayFromVoezData(
                        vTrack.ColorChange, vTrack.End, 0,
                        -vTrack.Start, 0,
                        0f, 1f
                        ),
                    StageIndex = 0,
                    HasTray    = false,
                    Speed      = 1f,
                    Angles     = { },
                };
            }
            data.SortNotesByTime();
            return(data);
        }