void InstantiateNotesData(MusicModel.NotesData notesData)
    {
        var editorModel = NotesEditorModel.Instance;

        editorModel.BPM.Value = notesData.BPM;
        editorModel.BeatOffsetSamples.Value = notesData.offset;

        foreach (var note in notesData.notes)
        {
            if (note.type == 1)
            {
                InstantiateNoteObject(notesData, note);
                continue;
            }

            var longNoteObjects = new MusicModel.Note[] { note }.Concat(note.notes)
            .Select(note_ => InstantiateNoteObject(notesData, note_))
            .ToList();

            for (int i = 1; i < longNoteObjects.Count; i++)
            {
                longNoteObjects[i].prev     = longNoteObjects[i - 1];
                longNoteObjects[i - 1].next = longNoteObjects[i];
            }
        }
    }
    NoteObject InstantiateNoteObject(MusicModel.NotesData notesData, MusicModel.Note note)
    {
        var noteObject = (Instantiate(noteObjectPrefab) as GameObject).GetComponent <NoteObject>();

        noteObject.notePosition   = new NotePosition(notesData.BPM, note.LPB, note.num, note.block);
        noteObject.noteType.Value = note.type == 2 ? NoteTypes.Long : NoteTypes.Normal;
        noteObject.transform.SetParent(notesRegion.transform);
        NotesEditorModel.Instance.NoteObjects.Add(noteObject.notePosition, noteObject);
        return(noteObject);
    }
Esempio n. 3
0
    public MusicModel.Note ConvertToNote(NoteObject noteObject)
    {
        var note = new MusicModel.Note();

        note.num   = noteObject.notePosition.num;
        note.block = noteObject.notePosition.block;
        note.LPB   = noteObject.notePosition.LPB;
        note.type  = noteObject.noteType.Value == NoteTypes.Long ? 2 : 1;
        note.notes = new List <MusicModel.Note>();
        return(note);
    }
    void InstantiateNotesData(MusicModel.NotesData notesData)
    {
        var editorModel = NotesEditorModel.Instance;

        editorModel.BPM.Value = notesData.BPM;
        editorModel.BeatOffsetSamples.Value = notesData.offset;

        foreach (var note in notesData.notes)
        {
            if (note.type == 1)
            {
                InstantiateNoteObject(notesData, note);
                continue;
            }

            var longNoteObjects = new MusicModel.Note[] { note }.Concat(note.notes)
                .Select(note_ => InstantiateNoteObject(notesData, note_))
                .ToList();

            for (int i = 1; i < longNoteObjects.Count; i++)
            {
                longNoteObjects[i].prev = longNoteObjects[i - 1];
                longNoteObjects[i - 1].next = longNoteObjects[i];
            }
        }
    }