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
This commit is contained in:
Pengu123 2022-05-04 18:05:05 +02:00
parent d41eaac105
commit 70a69a7c91
2 changed files with 19 additions and 10 deletions

View File

@ -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)

View File

@ -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;
}
}
}