diff --git a/Assets/Scripts/Games/CoinToss/CoinToss.cs b/Assets/Scripts/Games/CoinToss/CoinToss.cs index 755f3554a..70be60daa 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.DIRECTION_DOWN, CatchSuccess, CatchMiss, CatchEmpty); + coin = ScheduleInput(beat, 6f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty); } public void CatchSuccess(int state) diff --git a/Assets/Scripts/Games/PlayerActionEvent.cs b/Assets/Scripts/Games/PlayerActionEvent.cs index 6f9d197c8..2060499d8 100644 --- a/Assets/Scripts/Games/PlayerActionEvent.cs +++ b/Assets/Scripts/Games/PlayerActionEvent.cs @@ -77,13 +77,26 @@ namespace HeavenStudio.Games public bool IsCorrectInput() { + // This one is a mouthful but it's an evil good to detect the correct input + // Forgive me for those input type names return ( + //General inputs, both down and up (PlayerInput.Pressed() && inputType == InputType.STANDARD_DOWN) || (PlayerInput.AltPressed() && inputType == InputType.STANDARD_ALT_DOWN) || (PlayerInput.GetAnyDirectionDown() && inputType == InputType.DIRECTION_DOWN) || (PlayerInput.PressedUp() && inputType == InputType.STANDARD_UP) || (PlayerInput.AltPressedUp() && inputType == InputType.STANDARD_ALT_UP) || - (PlayerInput.GetAnyDirectionUp() && inputType == InputType.DIRECTION_UP) + (PlayerInput.GetAnyDirectionUp() && inputType == InputType.DIRECTION_UP) || + //Specific directional inputs + (PlayerInput.GetSpecificDirectionDown(PlayerInput.DOWN) && inputType == InputType.DIRECTION_DOWN_DOWN) || + (PlayerInput.GetSpecificDirectionDown(PlayerInput.UP) && inputType == InputType.DIRECTION_UP_DOWN) || + (PlayerInput.GetSpecificDirectionDown(PlayerInput.LEFT) && inputType == InputType.DIRECTION_LEFT_DOWN) || + (PlayerInput.GetSpecificDirectionDown(PlayerInput.RIGHT) && inputType == InputType.DIRECTION_RIGHT_DOWN) || + + (PlayerInput.GetSpecificDirectionUp(PlayerInput.DOWN) && inputType == InputType.DIRECTION_DOWN_UP) || + (PlayerInput.GetSpecificDirectionUp(PlayerInput.UP) && inputType == InputType.DIRECTION_UP_UP) || + (PlayerInput.GetSpecificDirectionUp(PlayerInput.LEFT) && inputType == InputType.DIRECTION_LEFT_UP) || + (PlayerInput.GetSpecificDirectionUp(PlayerInput.RIGHT) && inputType == InputType.DIRECTION_RIGHT_UP) ); } diff --git a/Assets/Scripts/InputType.cs b/Assets/Scripts/InputType.cs index b166d4706..845720494 100644 --- a/Assets/Scripts/InputType.cs +++ b/Assets/Scripts/InputType.cs @@ -6,12 +6,29 @@ using UnityEngine; namespace HeavenStudio { public enum InputType : int { + + //General + //------- + //Down STANDARD_DOWN = 0, STANDARD_ALT_DOWN = 1, DIRECTION_DOWN = 2, - + //Up STANDARD_UP = 3, STANDARD_ALT_UP = 4, - DIRECTION_UP = 5 + DIRECTION_UP = 5, + + //Specific + //-------- + //Down + DIRECTION_DOWN_DOWN = 6, + DIRECTION_UP_DOWN = 7, + DIRECTION_LEFT_DOWN = 8, + DIRECTION_RIGHT_DOWN = 9, + //Up + DIRECTION_DOWN_UP = 10, + DIRECTION_UP_UP = 11, + DIRECTION_LEFT_UP = 12, + DIRECTION_RIGHT_UP = 13 } } \ No newline at end of file diff --git a/Assets/Scripts/PlayerInput.cs b/Assets/Scripts/PlayerInput.cs index 187303cf9..c8f13aa21 100644 --- a/Assets/Scripts/PlayerInput.cs +++ b/Assets/Scripts/PlayerInput.cs @@ -7,6 +7,26 @@ namespace HeavenStudio public class PlayerInput { + //Clockwise + public const int UP = 0; + public const int RIGHT = 1; + public const int DOWN = 2; + public const int LEFT = 3; + + // 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; + } + + /*--------------------*/ + /* MAIN INPUT METHODS */ + /*--------------------*/ + + // BUTTONS + public static bool Pressed(bool includeDPad = false) { bool keyDown = Input.GetKeyDown(KeyCode.Z) || (includeDPad && GetAnyDirectionDown()); @@ -41,6 +61,8 @@ namespace HeavenStudio return Input.GetKey(KeyCode.X) && playerHasControl(); } + //Directions + public static bool GetAnyDirectionDown() { return (Input.GetKeyDown(KeyCode.UpArrow) @@ -68,13 +90,38 @@ namespace HeavenStudio } - - // The autoplay isn't activated AND - // The song is actually playing AND - // The GameManager allows you to Input - public static bool playerHasControl() + public static bool GetSpecificDirectionDown(int direction) { - return !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; + KeyCode targetCode = getKeyCode(direction); + if (targetCode == KeyCode.None) return false; + + return Input.GetKeyDown(targetCode) && playerHasControl(); } + + public static bool GetSpecificDirectionUp(int direction) + { + KeyCode targetCode = getKeyCode(direction); + if (targetCode == KeyCode.None) return false; + + return Input.GetKeyUp(targetCode) && playerHasControl(); + } + + + private static KeyCode getKeyCode(int direction) + { + KeyCode targetKeyCode; + + switch (direction) + { + case PlayerInput.UP: targetKeyCode = KeyCode.UpArrow; break; + case PlayerInput.DOWN: targetKeyCode = KeyCode.DownArrow; break; + case PlayerInput.LEFT: targetKeyCode = KeyCode.LeftArrow; break; + case PlayerInput.RIGHT: targetKeyCode = KeyCode.RightArrow; break; + default: targetKeyCode = KeyCode.None; break; + } + + return targetKeyCode; + } + } } \ No newline at end of file