Exemple #1
0
 void UpdateKeyState()
 {
     if (WasJustReleased())
     {
         keyState = KeyState.Up;
         PlaySoundOnPress(keyState);
         SetProperColor();
         CurrentlyPressedNoteEvent.Note_OnReleased(noteNumber);
     }
     if (WasPres())
     {
         keyState = KeyState.Down;
         PlaySoundOnPress(keyState);
         SetProperColor();
         CurrentlyPressedNoteEvent.Note_OnPressed(noteNumber);
     }
     keyboard.DetectKey();
 }
 public void DetectKey()
 {
     foreach (var key in keysCodes)
     {
         var singleNote = noteKeys[key].GetComponent <NoteIndicatorKeys>();
         if (Input.GetKeyDown(key))
         {
             singleNote.PlaySoundOnPress(NoteIndicatorKeys.KeyState.Down);
             singleNote.SetKeyState(NoteIndicatorKeys.KeyState.Down);
             singleNote.SetProperColor();
             CurrentlyPressedNoteEvent.Note_OnPressed(singleNote.GetNoteNumber);
         }
         if (Input.GetKeyUp(key))
         {
             singleNote.SetKeyState(NoteIndicatorKeys.KeyState.Up);
             singleNote.SetProperColor();
             CurrentlyPressedNoteEvent.Note_OnReleased(singleNote.GetNoteNumber);
         }
     }
 }