From 70a69a7c9168375f7e2dd78eec882a2be3327aa6 Mon Sep 17 00:00:00 2001 From: Pengu123 Date: Wed, 4 May 2022 18:05:05 +0200 Subject: [PATCH] Fixed Input bugs + Optimizations -- On the PlayerInput class -- FIXED: Bug where Directions input were still recorded even with autoplay on OPTIMIZED: Moved the conditions wether player had control in it's own method so we can re-use the same condition on new methods --- Assets/Scripts/Games/CoinToss/CoinToss.cs | 2 +- Assets/Scripts/PlayerInput.cs | 27 +++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/Games/CoinToss/CoinToss.cs b/Assets/Scripts/Games/CoinToss/CoinToss.cs index 70be60da..755f3554 100644 --- a/Assets/Scripts/Games/CoinToss/CoinToss.cs +++ b/Assets/Scripts/Games/CoinToss/CoinToss.cs @@ -74,7 +74,7 @@ namespace HeavenStudio.Games this.audienceReacting = audienceReacting; - coin = ScheduleInput(beat, 6f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty); + coin = ScheduleInput(beat, 6f, InputType.DIRECTION_DOWN, CatchSuccess, CatchMiss, CatchEmpty); } public void CatchSuccess(int state) diff --git a/Assets/Scripts/PlayerInput.cs b/Assets/Scripts/PlayerInput.cs index d994289a..187303cf 100644 --- a/Assets/Scripts/PlayerInput.cs +++ b/Assets/Scripts/PlayerInput.cs @@ -28,44 +28,53 @@ namespace HeavenStudio public static bool AltPressed() { - return Input.GetKeyDown(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; + return Input.GetKeyDown(KeyCode.X) && playerHasControl(); } public static bool AltPressedUp() { - return Input.GetKeyUp(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; + return Input.GetKeyUp(KeyCode.X) && playerHasControl(); } public static bool AltPressing() { - return Input.GetKey(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; + return Input.GetKey(KeyCode.X) && playerHasControl(); } public static bool GetAnyDirectionDown() { - return Input.GetKeyDown(KeyCode.UpArrow) + return (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.LeftArrow) - || Input.GetKeyDown(KeyCode.RightArrow); + || Input.GetKeyDown(KeyCode.RightArrow)) && playerHasControl(); } public static bool GetAnyDirectionUp() { - return Input.GetKeyUp(KeyCode.UpArrow) + return (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow) || Input.GetKeyUp(KeyCode.LeftArrow) - || Input.GetKeyUp(KeyCode.RightArrow); + || Input.GetKeyUp(KeyCode.RightArrow)) && playerHasControl(); } public static bool GetAnyDirection() { - return Input.GetKey(KeyCode.UpArrow) + return (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.LeftArrow) - || Input.GetKey(KeyCode.RightArrow); + || Input.GetKey(KeyCode.RightArrow)) && playerHasControl(); } + + + // The autoplay isn't activated AND + // The song is actually playing AND + // The GameManager allows you to Input + public static bool playerHasControl() + { + return !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; + } } } \ No newline at end of file