From 34e29efae819b99e67b3cb010aa72e509c686903 Mon Sep 17 00:00:00 2001 From: Pengu123 Date: Wed, 4 May 2022 20:37:52 +0200 Subject: [PATCH] More comments, new method to detect expected inputs IsExpectingInputNow() detects wether the player is expected to input something at the closest InputEvent --- Assets/Scripts/Games/Minigame.cs | 14 ++++++++++++++ Assets/Scripts/Games/PlayerActionEvent.cs | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Games/Minigame.cs b/Assets/Scripts/Games/Minigame.cs index 0499e450..8a6fe250 100644 --- a/Assets/Scripts/Games/Minigame.cs +++ b/Assets/Scripts/Games/Minigame.cs @@ -68,6 +68,7 @@ namespace HeavenStudio.Games return evt; } + //Clean up method used whenever a PlayerActionEvent has finished public void RemoveScheduledInput(PlayerActionEvent evt) { scheduledInputs.Remove(evt); @@ -98,6 +99,19 @@ namespace HeavenStudio.Games return closest; } + //Hasn't been tested yet. *Should* work. + //Can be used to detect if the user is expected to input something now or not + //Useful for strict call and responses games like Tambourine + public bool IsExpectingInputNow() + { + PlayerActionEvent input = GetClosestScheduledInput(); + if (input == null) return false; + + return input.IsExpectingInputNow(); + } + + + // hopefully these will fix the lowbpm problem public static float EarlyTime() { diff --git a/Assets/Scripts/Games/PlayerActionEvent.cs b/Assets/Scripts/Games/PlayerActionEvent.cs index 3a6757a3..4b3b4bcc 100644 --- a/Assets/Scripts/Games/PlayerActionEvent.cs +++ b/Assets/Scripts/Games/PlayerActionEvent.cs @@ -86,7 +86,13 @@ namespace HeavenStudio.Games Blank(); } } - } + } + + public bool IsExpectingInputNow() + { + float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, timer); + return normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.EndTime(); + } public bool IsCorrectInput() {