//在目前位置增加一個音符 public void onAddNote() { if (editor.brush.currentBrush == NoteType.Null) { print(editor.brush.currentBrush.ToString()); return; } Note note = NoteUtility.GenerateNote(editor.brush.currentBrush); var length = (int)editor.trackMapEditor.noteLength.Value; var offset = editor.trackMapEditor.noteOffset.Value; var angle = editor.trackMapEditor.noteAngle.Value; if (editor.getCurrentNote != null) { note.position = length + editor.getCurrentNoteGridPosition; } else { note.position = editor.getCurrentNoteGridPosition; } note.lenght = length; note.Xoffset = offset; note.angle = angle; editor.getTrackMap.Notes.Add(note); editor.getTrackMap.Sort(); editor.getCurrentNoteIndex = editor.getTrackMap.Notes.IndexOf(note); }
//在目前位置插入一個音符,之後的音符會位移這個音符的長度 public void onInsertNote() { if (editor.brush.currentBrush == NoteType.Null) { print(editor.brush.currentBrush.ToString()); return; } Note note = NoteUtility.GenerateNote(editor.brush.currentBrush); var length = (int)editor.trackMapEditor.noteLength.Value; var offset = editor.trackMapEditor.noteOffset.Value; var angle = editor.trackMapEditor.noteAngle.Value; note.position = editor.getCurrentNoteGridPosition; note.lenght = length; note.Xoffset = offset; note.angle = angle; editor.getTrackMap.Notes.Add(note); editor.getCurrentNoteIndex = editor.getTrackMap.Notes.IndexOf(note); for (int i = 0; i < editor.getTrackMap.Notes.Count; i++) { if (editor.getTrackMap.Notes[i] == note || editor.getTrackMap.Notes[i].position < note.position) { continue; } editor.getTrackMap.Notes[i].position += note.lenght; } editor.getTrackMap.Sort(); editor.getCurrentNoteIndex = editor.getTrackMap.Notes.IndexOf(note); }