Skip to content

Commit

Permalink
Hit available notes if pressed too early
Browse files Browse the repository at this point in the history
  • Loading branch information
Enovale committed Feb 4, 2021
1 parent 04461d5 commit 5d1f561
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Assets/Scripts/InputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ private void HandleInput()
}
}
}
else
{
// Hit the next possible note if you try to hit earlier than the timing window
var spawned1 = musicHandler.GetSpawnedButtons(true).FirstOrDefault();
var spawned2 = musicHandler.GetSpawnedButtons(false).FirstOrDefault();

if (spawned1 != null && spawned2 != null)
HandlePressNote(
Math.Abs(Math.Min(spawned1.Button.Beat, spawned2.Button.Beat) - spawned1.Button.Beat) < 0.05
? spawned1.Button
: spawned2.Button);
else if (spawned1 != null || spawned2 != null)
HandlePressNote(spawned1 != null ? spawned1.Button : spawned2.Button);
}

var buttonHit = false;
foreach (var button in trackOneNotes)
Expand All @@ -96,7 +110,7 @@ private void HandleInput()
// If you hit both on the same frame, pretend like you didnt hit the first one.
if (Input.GetKeyDown(button.Key) && Input.GetKeyDown(button.KeyAlt))
{
btnClass.Hit(pos, bpm);
HandlePressNote(btnClass);
break;
}
else if (Input.GetKeyDown(button.Key) || Input.GetKeyDown(button.KeyAlt))
Expand Down

0 comments on commit 5d1f561

Please sign in to comment.