void Update()
{
if (MidiInput.GetKeyDown(keyNumber + 21))
{
isDown = true;
if (keyNumber == song.noteList[0].noteNum)
{
// If the MIDI input matches the current target note...
material.color = Color.Lerp(material.color, Color.blue, 1 - Time.deltaTime);
if (song.noteList.Count == 1)
{
text.Invoke("Complete", 0);
}
else
{
// Pop queue, trigger corresponding effects, update text
front.Invoke("PopEffect", 0f);
song.noteList.RemoveAt(0);
text.text_data.RemoveAt(0);
text.Invoke("Refresh", 0);
}
}
else
{
// If note played is incorrect, change color of both the note text and corresponding
// piano key to red
material.color = Color.Lerp(material.color, Color.red, 1 - Time.deltaTime);
front.front.color = Color.Lerp(front.text.color, Color.red, 1 - Time.deltaTime);
Debug.LogFormat("WRONG NOTE! Expected: {0} {1}", song.noteList[0].noteName, song.noteList[0].noteOctave, song.noteList[0].duration);
}
}
else if (MidiInput.GetKeyUp(keyNumber + 21))
{
// Reset colors to default if no note is played
isDown = false;
material.color = Color.Lerp(material.color, col, 1 - Time.deltaTime);
front.front.color = Color.Lerp(front.text.color, Color.green, 1 - Time.deltaTime);
}
}