From d9550afaec366a5bb46809173b0c92955d0b82f6 Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Mon, 21 Feb 2022 22:43:31 -0700 Subject: [PATCH] Tweezers: Allowed inputting via arrow keys. Editor: Remix files now saved as .tengoku files (.rhmania files can still be opened via the editor). --- Assets/Scripts/Games/RhythmTweezers/Hair.cs | 2 +- .../Scripts/Games/RhythmTweezers/LongHair.cs | 4 +- .../Scripts/Games/RhythmTweezers/Tweezers.cs | 2 +- Assets/Scripts/LevelEditor/Editor.cs | 4 +- Assets/Scripts/PlayerInput.cs | 42 ++++++++++++++++--- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/Games/RhythmTweezers/Hair.cs b/Assets/Scripts/Games/RhythmTweezers/Hair.cs index f1ac1df4..1abd7409 100644 --- a/Assets/Scripts/Games/RhythmTweezers/Hair.cs +++ b/Assets/Scripts/Games/RhythmTweezers/Hair.cs @@ -28,7 +28,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers float stateBeat = Conductor.instance.GetPositionFromMargin(createBeat + game.tweezerBeatOffset + game.beatInterval, 1f); StateCheck(stateBeat); - if (PlayerInput.Pressed()) + if (PlayerInput.Pressed(true)) { if (state.perfect) { diff --git a/Assets/Scripts/Games/RhythmTweezers/LongHair.cs b/Assets/Scripts/Games/RhythmTweezers/LongHair.cs index ba895df7..f201c07a 100644 --- a/Assets/Scripts/Games/RhythmTweezers/LongHair.cs +++ b/Assets/Scripts/Games/RhythmTweezers/LongHair.cs @@ -39,7 +39,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers stateBeat = Conductor.instance.GetPositionFromMargin(createBeat + game.tweezerBeatOffset + game.beatInterval, 1f); StateCheck(stateBeat); - if (PlayerInput.Pressed()) + if (PlayerInput.Pressed(true)) { if (state.perfect) { @@ -60,7 +60,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers stateBeat = Conductor.instance.GetPositionFromMargin(createBeat + game.tweezerBeatOffset + game.beatInterval + 0.5f, 1f); StateCheck(stateBeat); - if (PlayerInput.PressedUp()) + if (PlayerInput.PressedUp(true)) { // It's possible to release earlier than earlyTime, // and the hair will automatically be released before lateTime, diff --git a/Assets/Scripts/Games/RhythmTweezers/Tweezers.cs b/Assets/Scripts/Games/RhythmTweezers/Tweezers.cs index 9e4b5a64..da87da1f 100644 --- a/Assets/Scripts/Games/RhythmTweezers/Tweezers.cs +++ b/Assets/Scripts/Games/RhythmTweezers/Tweezers.cs @@ -28,7 +28,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers private void LateUpdate() { - if (PlayerInput.Pressed()) + if (PlayerInput.Pressed(true)) { if (!pluckingThisFrame) // Did you do a successful pluck earlier in the frame? { diff --git a/Assets/Scripts/LevelEditor/Editor.cs b/Assets/Scripts/LevelEditor/Editor.cs index 351b5cec..4659bad3 100644 --- a/Assets/Scripts/LevelEditor/Editor.cs +++ b/Assets/Scripts/LevelEditor/Editor.cs @@ -281,7 +281,7 @@ namespace RhythmHeavenMania.Editor { var extensions = new[] { - new ExtensionFilter("Rhythm Heaven Mania Remix File", "rhmania") + new ExtensionFilter("Heaven Studio Remix File", "tengoku") }; StandaloneFileBrowser.SaveFilePanelAsync("Save Remix As", "", "remix_level", extensions, (string path) => @@ -323,7 +323,7 @@ namespace RhythmHeavenMania.Editor { var extensions = new[] { - new ExtensionFilter("Rhythm Heaven Mania Remix File", "rhmania") + new ExtensionFilter("Heaven Studio Remix File", new string[] { "tengoku", "rhmania" }) }; StandaloneFileBrowser.OpenFilePanelAsync("Open Remix", "", extensions, false, (string[] paths) => diff --git a/Assets/Scripts/PlayerInput.cs b/Assets/Scripts/PlayerInput.cs index 513b9b91..fba3208f 100644 --- a/Assets/Scripts/PlayerInput.cs +++ b/Assets/Scripts/PlayerInput.cs @@ -6,19 +6,22 @@ namespace RhythmHeavenMania { public class PlayerInput { - public static bool Pressed() + public static bool Pressed(bool includeDPad = false) { - return Input.GetKeyDown(KeyCode.Z) && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + bool keyDown = Input.GetKeyDown(KeyCode.Z) || (includeDPad && GetAnyDirectionDown()); + return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying; } - public static bool PressedUp() + public static bool PressedUp(bool includeDPad = false) { - return Input.GetKeyUp(KeyCode.Z) && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + bool keyUp = Input.GetKeyUp(KeyCode.Z) || (includeDPad && GetAnyDirectionUp()); + return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying; } - public static bool Pressing() + public static bool Pressing(bool includeDPad = false) { - return Input.GetKey(KeyCode.Z) && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + bool pressing = Input.GetKey(KeyCode.Z) || (includeDPad && GetAnyDirection()); + return pressing && !GameManager.instance.autoplay && Conductor.instance.isPlaying; } @@ -36,5 +39,32 @@ namespace RhythmHeavenMania { return Input.GetKey(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying; } + + public static bool GetAnyDirectionDown() + { + return Input.GetKeyDown(KeyCode.UpArrow) + || Input.GetKeyDown(KeyCode.DownArrow) + || Input.GetKeyDown(KeyCode.LeftArrow) + || Input.GetKeyDown(KeyCode.RightArrow); + + } + + public static bool GetAnyDirectionUp() + { + return Input.GetKeyUp(KeyCode.UpArrow) + || Input.GetKeyUp(KeyCode.DownArrow) + || Input.GetKeyUp(KeyCode.LeftArrow) + || Input.GetKeyUp(KeyCode.RightArrow); + + } + + public static bool GetAnyDirection() + { + return Input.GetKey(KeyCode.UpArrow) + || Input.GetKey(KeyCode.DownArrow) + || Input.GetKey(KeyCode.LeftArrow) + || Input.GetKey(KeyCode.RightArrow); + + } } } \ No newline at end of file