public IEnumerable <Pair <long, Action> > MapTrack(ProgramTrack track, MappingInfo info) { foreach (var pair in track.EventPairs) { // runningInfo.ApplyEvent(pair.First, pair.Second); var @event = pair.Second; switch (@event) { case NoteOnEvent onEvent: { var microsTime = info.GetMicros(pair.First); var noteNumber = onEvent.NoteNumber; void OnAction() { if (_onCount[noteNumber]++ != 0) { return; } var glowingObject = _glowingArray.GetGlowingForNote(noteNumber)?.Glowing; if (glowingObject != null) { glowingObject.IsGlowing = true; } } yield return(new Pair <long, Action>(microsTime, OnAction)); break; } case NoteOffEvent offEvent: { var microsTime = info.GetMicros(pair.First); var noteNumber = offEvent.NoteNumber; void OffAction() { if (--_onCount[noteNumber] != 0) { return; } var glowingObject = _glowingArray.GetGlowingForNote(noteNumber)?.Glowing; if (glowingObject != null) { glowingObject.IsGlowing = false; } } yield return(new Pair <long, Action>(microsTime, OffAction)); break; } } } }
public IEnumerable <Pair <long, Action> > MapTrack(ProgramTrack track, MappingInfo info) { foreach (var pair in track.EventPairs) { switch (pair.Second) { case NoteOnEvent noe: yield return(new Pair <long, Action>(info.GetMicros(pair.First), () => _movingObject.AddObject(noe))); break; case NoteOffEvent noe: yield return(new Pair <long, Action>(info.GetMicros(pair.First), () => _movingObject.RemoveObject(noe))); break; } } }
private IEnumerable <Pair <long, LaunchInfo> > AirMapper(ProgramTrack track, MappingInfo info) { foreach (var pair in track.EventPairs) { if (pair.Second is NoteOnEvent noe) { yield return(new Pair <long, LaunchInfo>( info.GetMicros(pair.First), new LaunchInfo( _airLauncher.GetGlobalTranslation() + Vector3.Right * (0.2f * noe.NoteNumber), Vector3.Back * 2 + Vector3.Down))); } } }