mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-08 18:55:07 +00:00
Added Support for specific direction inputs
Added some comments on the PlayerInput class too for clarity
This commit is contained in:
parent
70a69a7c91
commit
ba8d2132ce
4 changed files with 87 additions and 10 deletions
|
@ -74,7 +74,7 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
this.audienceReacting = audienceReacting;
|
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)
|
public void CatchSuccess(int state)
|
||||||
|
|
|
@ -77,13 +77,26 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
public bool IsCorrectInput()
|
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 (
|
return (
|
||||||
|
//General inputs, both down and up
|
||||||
(PlayerInput.Pressed() && inputType == InputType.STANDARD_DOWN) ||
|
(PlayerInput.Pressed() && inputType == InputType.STANDARD_DOWN) ||
|
||||||
(PlayerInput.AltPressed() && inputType == InputType.STANDARD_ALT_DOWN) ||
|
(PlayerInput.AltPressed() && inputType == InputType.STANDARD_ALT_DOWN) ||
|
||||||
(PlayerInput.GetAnyDirectionDown() && inputType == InputType.DIRECTION_DOWN) ||
|
(PlayerInput.GetAnyDirectionDown() && inputType == InputType.DIRECTION_DOWN) ||
|
||||||
(PlayerInput.PressedUp() && inputType == InputType.STANDARD_UP) ||
|
(PlayerInput.PressedUp() && inputType == InputType.STANDARD_UP) ||
|
||||||
(PlayerInput.AltPressedUp() && inputType == InputType.STANDARD_ALT_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)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,29 @@ using UnityEngine;
|
||||||
namespace HeavenStudio
|
namespace HeavenStudio
|
||||||
{
|
{
|
||||||
public enum InputType : int {
|
public enum InputType : int {
|
||||||
|
|
||||||
|
//General
|
||||||
|
//-------
|
||||||
|
//Down
|
||||||
STANDARD_DOWN = 0,
|
STANDARD_DOWN = 0,
|
||||||
STANDARD_ALT_DOWN = 1,
|
STANDARD_ALT_DOWN = 1,
|
||||||
DIRECTION_DOWN = 2,
|
DIRECTION_DOWN = 2,
|
||||||
|
//Up
|
||||||
STANDARD_UP = 3,
|
STANDARD_UP = 3,
|
||||||
STANDARD_ALT_UP = 4,
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,26 @@ namespace HeavenStudio
|
||||||
public class PlayerInput
|
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)
|
public static bool Pressed(bool includeDPad = false)
|
||||||
{
|
{
|
||||||
bool keyDown = Input.GetKeyDown(KeyCode.Z) || (includeDPad && GetAnyDirectionDown());
|
bool keyDown = Input.GetKeyDown(KeyCode.Z) || (includeDPad && GetAnyDirectionDown());
|
||||||
|
@ -41,6 +61,8 @@ namespace HeavenStudio
|
||||||
return Input.GetKey(KeyCode.X) && playerHasControl();
|
return Input.GetKey(KeyCode.X) && playerHasControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Directions
|
||||||
|
|
||||||
public static bool GetAnyDirectionDown()
|
public static bool GetAnyDirectionDown()
|
||||||
{
|
{
|
||||||
return (Input.GetKeyDown(KeyCode.UpArrow)
|
return (Input.GetKeyDown(KeyCode.UpArrow)
|
||||||
|
@ -68,13 +90,38 @@ namespace HeavenStudio
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool GetSpecificDirectionDown(int direction)
|
||||||
// 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;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue