protected sealed override void OnNoteStop(ENoteColour aNoteColour, MusicalNote note) { if (aNoteColour == noteColour) { Deactivate(note); m_isActive = false; } }
protected sealed override void OnNoteStart(ENoteColour aNoteColour, MusicalNote note) { if (aNoteColour == noteColour) { Activate(note); m_isActive = true; } }
void TriggerNoteStop(ENoteColour colour) { m_animator.SetInteger("NoteColour", (int)colour); // Triggering the transition to the Stopped state! m_animator.ResetTrigger("TNoteStarted"); m_animator.SetTrigger("TNoteStopped"); m_pressedColours.Remove(colour); }
public void StopAllPlayingNotPressedNotes() { for (int i = 0; i < m_playingColours.Count; ++i) { ENoteColour colour = m_playingColours[i]; if (!m_pressedColours.Contains(colour) && StopNote(colour)) { --i; } } }
public void StopAllPlayingNotes() { for (int i = 0; i < m_playingColours.Count; ++i) { ENoteColour colour = m_playingColours[i]; if (!StopNote(colour)) { --i; } } }
public bool PlayNote(ENoteColour colour, MusicalNote note) { int voice = m_instrumentSource.StartNote(note); bool success = voice != -1; if (success) { SetPlayingVoice(colour, voice); m_events.playerNoteStartEvent.Invoke(colour, note); } return(success); }
void TriggerNoteStart(ENoteColour colour, MusicalNote note) { // Pass info to the StateMachine through the Animator. m_animator.SetInteger("NoteColour", (int)colour); m_animator.SetInteger("NoteTone", note.tone); m_animator.SetFloat("NoteVolume", (float)note.volume); m_animator.SetFloat("NotePanning", (float)note.panning); // Triggering the transition to the Playing state! m_animator.ResetTrigger("TNoteStopped"); m_animator.SetTrigger("TNoteStarted"); m_pressedColours.Add(colour); }
/// <summary> /// /// </summary> /// <returns>true on success, false on failure.</returns> public bool StopNote(ENoteColour colour) { int voice = GetPlayingVoice(colour); Assert.IsTrue(voice >= 0 && voice < m_instrumentSource.GetNumberVoices()); MusicalNote note = m_instrumentSource.GetNote(voice); bool success = m_instrumentSource.StopNote(voice); if (success) { UnsetPlayingVoice(colour); m_events.playerNoteStopEvent.Invoke(colour, note); } return(success); }
protected override void OnStateEnterInternal(Animator animator) { // Resetting the corresponding trigger. animator.ResetTrigger("TNoteStarted"); owner.StopAllPlayingNotes(); ENoteColour colour = (ENoteColour)animator.GetInteger("NoteColour"); m_note = new MusicalNote( animator.GetInteger("NoteTone"), animator.GetFloat("NoteVolume") ); // Debug.Log($"Start {colour}"); owner.PlayNote(colour, m_note); }
void Update() { for (int toneIndex = 0; toneIndex < tones.Length; ++toneIndex) { KeyCode key = keys[toneIndex]; ENoteColour colour = (ENoteColour)toneIndex; if (Input.GetKeyDown(key)) { int tone = tones[toneIndex]; TriggerNoteStart(colour, new MusicalNote(tone, volume)); } else if (Input.GetKeyUp(key)) { TriggerNoteStop(colour); } } }
public static Color GetColour(ENoteColour noteColour) { Color colour = Color.clear; switch (noteColour) { case ENoteColour.eBlue: colour = Color.blue; break; case ENoteColour.eGreen: colour = Color.green; break; case ENoteColour.eYellow: colour = Color.yellow; break; case ENoteColour.eOrange: colour = Color.Lerp(Color.red, Color.yellow, 0.5f); break; case ENoteColour.eRed: colour = Color.red; break; } return(colour); }
void UnsetPlayingVoice(ENoteColour colour) { m_playingVoices[(int)colour] = -1; m_playingColours.Remove(colour); }
void SetPlayingVoice(ENoteColour colour, int voice) { m_playingVoices[(int)colour] = voice; m_playingColours.Add(colour); }
int GetPlayingVoice(ENoteColour colour) { return(m_playingVoices[(int)colour]); }
protected virtual void OnNoteStop(ENoteColour noteColour, MusicalNote note) { }
void OnNoteStartInRange(ENoteColour noteColour, MusicalNote note) { m_inRangePlayingNotes.Add(new Tuple <ENoteColour, MusicalNote>(noteColour, note)); OnNoteStart(noteColour, note); }
void OnNoteStopInRange(ENoteColour noteColour, MusicalNote note) { m_inRangePlayingNotes.RemoveAll(el => el.Item1 == noteColour); OnNoteStop(noteColour, note); }
void OnNoteStartOutOfRange(ENoteColour noteColour, MusicalNote note) { m_outOfRangePlayingNotes.Add(new Tuple <ENoteColour, MusicalNote>(noteColour, note)); }
void OnNoteStopOutOfRange(ENoteColour noteColour, MusicalNote note) { m_outOfRangePlayingNotes.RemoveAll(el => el.Item1 == noteColour); }
protected virtual void OnNoteStart(ENoteColour aNoteColour, MusicalNote note) { }