diff --git a/Assets/Scripts/Games/CheerReaders/CheerReaders.cs b/Assets/Scripts/Games/CheerReaders/CheerReaders.cs index 84228c1fe..1b0aa5001 100644 --- a/Assets/Scripts/Games/CheerReaders/CheerReaders.cs +++ b/Assets/Scripts/Games/CheerReaders/CheerReaders.cs @@ -1,4 +1,5 @@ using HeavenStudio.Util; +using HeavenStudio.InputSystem; using JetBrains.Annotations; using Starpelly.Transformer; using System; @@ -106,9 +107,9 @@ namespace HeavenStudio.Games.Loaders defaultLength = 0.5f } }, - new List() {"rvl", "normal"}, + new List() { "rvl", "normal" }, "rvlbooks", "en", - new List() {"en"} + new List() { "en" } ); } } @@ -176,6 +177,42 @@ namespace HeavenStudio.Games float currentZoomCamLength; private List allCameraEvents = new List(); + const int IAAltDownCat = 4; + const int IAAltUpCat = 5; + + protected static bool IA_PadAltPress(out double dt) + { + return PlayerInput.GetPadDown(InputController.ActionsPad.South, out dt); + } + protected static bool IA_BatonAltPress(out double dt) + { + return PlayerInput.GetSqueezeDown(out dt); + } + protected static bool IA_TouchAltPress(out double dt) + { + return PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt) + && instance.IsExpectingInputNow(InputAction_AltStart); + } + + protected static bool IA_PadAltRelease(out double dt) + { + return PlayerInput.GetPadUp(InputController.ActionsPad.South, out dt); + } + protected static bool IA_BatonAltRelease(out double dt) + { + return PlayerInput.GetSqueezeUp(out dt); + } + + public static PlayerInput.InputAction InputAction_AltStart = + new("RvlBookAltStart", new int[] { IAAltDownCat, IAAltDownCat, IAAltDownCat }, + IA_PadAltPress, IA_TouchAltPress, IA_BatonAltPress); + public static PlayerInput.InputAction InputAction_AltFinish = + new("RvlBookAltFinish", new int[] { IAAltUpCat, IAFlickCat, IAAltUpCat }, + IA_PadAltRelease, IA_TouchFlick, IA_BatonAltRelease); + public static PlayerInput.InputAction InputAction_TouchRelease = + new("NtrIdolTouchRelease", new int[] { IAEmptyCat, IAReleaseCat, IAEmptyCat }, + IA_Empty, IA_TouchBasicRelease, IA_Empty); + void OnDestroy() { SoundByte.KillLoop(SpinningLoop, 0.5f); @@ -289,14 +326,29 @@ namespace HeavenStudio.Games } } } - if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN)) + if (PlayerInput.GetIsAction(InputAction_BasicPress) && !IsExpectingInputNow(InputAction_BasicPress)) { - player.FlipBook(false); - missPoster.SetActive(false); - SoundByte.PlayOneShotGame("cheerReaders/miss"); - ScoreMiss(1f); + if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch + || (PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch && !IsExpectingInputNow(InputAction_AltStart))) + { + player.FlipBook(false); + missPoster.SetActive(false); + SoundByte.PlayOneShotGame("cheerReaders/miss"); + ScoreMiss(1f); + } } - if (PlayerInput.AltPressed() && !IsExpectingInputNow(InputType.STANDARD_ALT_DOWN)) + if (PlayerInput.GetIsAction(InputAction_TouchRelease) && player.isSpinning) + { + if (PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch && !IsExpectingInputNow(InputAction_AltFinish)) + { + player.FlipBook(false); + missPoster.SetActive(false); + SoundByte.PlayOneShotGame("cheerReaders/miss"); + SoundByte.KillLoop(SpinningLoop, 0f); + ScoreMiss(1f); + } + } + if (PlayerInput.GetIsAction(InputAction_AltStart) && !IsExpectingInputNow(InputAction_AltStart)) { SoundByte.PlayOneShotGame("cheerReaders/doingoing"); player.StartSpinBook(); @@ -304,7 +356,7 @@ namespace HeavenStudio.Games SpinningLoop = SoundByte.PlayOneShotGame("cheerReaders/bookSpinLoop", -1, 1, 1, true); ScoreMiss(1f); } - if (PlayerInput.AltPressedUp() && !IsExpectingInputNow(InputType.STANDARD_ALT_UP)) + if (PlayerInput.GetIsAction(InputAction_AltFinish) && !IsExpectingInputNow(InputAction_AltFinish) && player.isSpinning) { SoundByte.PlayOneShotGame("cheerReaders/doingoing"); player.StopSpinBook(); @@ -485,7 +537,7 @@ namespace HeavenStudio.Games public void OneTwoThree(double beat, int whoSpeaks) { canBop = false; - ScheduleInput(beat, 2, InputType.STANDARD_DOWN, JustFlip, MissFlip, Nothing); + ScheduleInput(beat, 2, InputAction_BasicPress, JustFlip, MissFlip, Nothing); List soundsToPlay = new List() { new MultiSound.Sound("cheerReaders/bookHorizontal", beat), @@ -613,7 +665,7 @@ namespace HeavenStudio.Games public void ItsUpToYou(double beat, int whoSpeaks) { canBop = false; - ScheduleInput(beat, 2, InputType.STANDARD_DOWN, JustFlip, MissFlip, Nothing); + ScheduleInput(beat, 2, InputAction_BasicPress, JustFlip, MissFlip, Nothing); List soundsToPlay = new List() { new MultiSound.Sound("cheerReaders/bookVertical", beat), @@ -771,7 +823,7 @@ namespace HeavenStudio.Games public void LetsGoReadABunchaBooks(double beat, int whoSpeaks) { canBop = false; - ScheduleInput(beat, 2, InputType.STANDARD_DOWN, JustFlip, MissFlip, Nothing); + ScheduleInput(beat, 2, InputAction_BasicPress, JustFlip, MissFlip, Nothing); List soundsToPlay = new List() { new MultiSound.Sound("cheerReaders/letsGoRead", beat), @@ -957,7 +1009,7 @@ namespace HeavenStudio.Games public void RahRahSisBoomBaBoom(double beat, int whoSpeaks, bool consecutive) { canBop = false; - ScheduleInput(beat, 2.5f, InputType.STANDARD_DOWN, JustFlipBoom, MissFlip, Nothing); + ScheduleInput(beat, 2.5f, InputAction_BasicPress, JustFlipBoom, MissFlip, Nothing); List soundsToPlay = new List() { new MultiSound.Sound("cheerReaders/bookDiagonal", beat + 0.5f), @@ -1168,8 +1220,8 @@ namespace HeavenStudio.Games { canBop = false; float actualLength = length * 0.25f; - ScheduleInput(beat, 2 * actualLength, InputType.STANDARD_ALT_DOWN, JustHoldSpin, MissFlip, Nothing); - ScheduleInput(beat, 3 * actualLength, InputType.STANDARD_ALT_UP, JustReleaseSpin, MissFlip, Nothing); + ScheduleInput(beat, 2 * actualLength, InputAction_AltStart, JustHoldSpin, MissFlip, Nothing); + ScheduleInput(beat, 3 * actualLength, InputAction_AltFinish, JustReleaseSpin, MissFlip, Nothing).IsHittable = IsReleaseSpinHittable; List soundsToPlay = new List(); if (whistle) { @@ -1442,6 +1494,10 @@ namespace HeavenStudio.Games playerMask.SetActive(false); missPoster.SetActive(false); SoundByte.PlayOneShotGame("cheerReaders/doingoing"); + + if (SpinningLoop != null) + SoundByte.KillLoop(SpinningLoop, 0f); + player.Miss(); shouldDoSuccessZoom = false; foreach (var girl in allGirls) @@ -1450,6 +1506,11 @@ namespace HeavenStudio.Games } } - void Nothing(PlayerActionEvent caller) {} + void Nothing(PlayerActionEvent caller) { } + + bool IsReleaseSpinHittable() + { + return player.isSpinning; + } } } diff --git a/Assets/Scripts/Games/CheerReaders/RvlCharacter.cs b/Assets/Scripts/Games/CheerReaders/RvlCharacter.cs index 9f124733b..d52b551a1 100644 --- a/Assets/Scripts/Games/CheerReaders/RvlCharacter.cs +++ b/Assets/Scripts/Games/CheerReaders/RvlCharacter.cs @@ -12,6 +12,7 @@ namespace HeavenStudio.Games.Scripts_CheerReaders [SerializeField] GameObject blushLeft; [SerializeField] GameObject blushRight; public bool bookIsWhite = true; + public bool isSpinning; public GameObject posterBook; bool bookIsOpen; bool noBop; @@ -136,6 +137,7 @@ namespace HeavenStudio.Games.Scripts_CheerReaders BaseAnim.Play(bookIsWhite ? "MissWhite" : "MissBlack", 0, 0); noBop = true; missed = true; + isSpinning = false; } public void Stare() @@ -146,12 +148,13 @@ namespace HeavenStudio.Games.Scripts_CheerReaders public void FlipBook(bool hit = true) { posterBook.SetActive(false); - if (hit) canOpenBook = false; + canOpenBook = !hit; + isSpinning = hit; if (bookIsWhite != game.shouldBeBlack && hit && player) { RepositionBook(); return; - } + } BaseAnim.DoScaledAnimationAsync(bookIsWhite ? "WhitetoBlack" : "BlacktoWhite", 0.5f); bookIsWhite = !bookIsWhite; bookIsOpen = true; @@ -173,6 +176,7 @@ namespace HeavenStudio.Games.Scripts_CheerReaders BaseAnim.DoScaledAnimationAsync(bookIsWhite ? "SpinfromWhite" : "SpinfromBlack", 0.5f); bookIsOpen = true; noBop = true; + isSpinning = true; } public void StopSpinBook() @@ -182,6 +186,7 @@ namespace HeavenStudio.Games.Scripts_CheerReaders BaseAnim.DoScaledAnimationAsync("OpenBook", 0.5f); bookIsOpen = true; noBop = true; + isSpinning = false; } } } diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs index 955dedb9b..85bcd1591 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs @@ -710,9 +710,9 @@ namespace HeavenStudio.InputSystem return joyBtStateCurrent.stickRX; case InputAxis.AxisRStickY: return joyBtStateCurrent.stickRY; - case InputAxis.TouchpadX: //isn't updated for now, so always returns 0f + case InputAxis.PointerX: //isn't updated for now, so always returns 0f //return joyTouchStateCurrent.t0X; - case InputAxis.TouchpadY: + case InputAxis.PointerY: //return joyTouchStateCurrent.t0Y; default: return 0f; @@ -727,7 +727,7 @@ namespace HeavenStudio.InputSystem return new Vector3(joyBtStateCurrent.stickLX, joyBtStateCurrent.stickLY, 0f); case InputVector.RStick: return new Vector3(joyBtStateCurrent.stickRX, joyBtStateCurrent.stickRY, 0f); - case InputVector.Touchpad: + case InputVector.Pointer: return new Vector3(joyTouchStateCurrent.t0X, joyTouchStateCurrent.t0Y, 0f); case InputVector.Accelerometer: return new Vector3(joyImuStateCurrent.accelX, joyImuStateCurrent.accelY, joyImuStateCurrent.accelZ); @@ -976,7 +976,7 @@ namespace HeavenStudio.InputSystem return false; } - public override bool GetSwipe(out double dt) + public override bool GetSlide(out double dt) { dt = 0; return false; @@ -1030,5 +1030,22 @@ namespace HeavenStudio.InputSystem { return ControlStyles.Pad; } + + public override bool GetSqueezeDown(out double dt) + { + dt = 0; + return false; + } + + public override bool GetSqueezeUp(out double dt) + { + dt = 0; + return false; + } + + public override bool GetSqueeze() + { + return false; + } } } \ No newline at end of file diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs index 31941c899..890494b3b 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs @@ -271,7 +271,7 @@ namespace HeavenStudio.InputSystem return false; } - public override bool GetSwipe(out double dt) + public override bool GetSlide(out double dt) { dt = 0; return false; @@ -292,5 +292,22 @@ namespace HeavenStudio.InputSystem { return ControlStyles.Pad; } + + public override bool GetSqueezeDown(out double dt) + { + dt = 0; + return false; + } + + public override bool GetSqueezeUp(out double dt) + { + dt = 0; + return false; + } + + public override bool GetSqueeze() + { + return false; + } } } \ No newline at end of file diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs index 1c12b2344..3edcbd252 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs @@ -369,7 +369,7 @@ namespace HeavenStudio.InputSystem return hasFlicked; } - public override bool GetSwipe(out double dt) + public override bool GetSlide(out double dt) { dt = hasSwiped ? Time.realtimeSinceStartupAsDouble - timeMoveChange : 0; return hasSwiped; @@ -390,5 +390,22 @@ namespace HeavenStudio.InputSystem { return ControlStyles.Touch; } + + public override bool GetSqueezeDown(out double dt) + { + dt = 0; + return false; + } + + public override bool GetSqueezeUp(out double dt) + { + dt = 0; + return false; + } + + public override bool GetSqueeze() + { + return false; + } } } \ No newline at end of file diff --git a/Assets/Scripts/InputSystem/InputController.cs b/Assets/Scripts/InputSystem/InputController.cs index ce02cd63f..3e8f2617c 100644 --- a/Assets/Scripts/InputSystem/InputController.cs +++ b/Assets/Scripts/InputSystem/InputController.cs @@ -19,17 +19,20 @@ namespace HeavenStudio.InputSystem AxisLStickY = 1, AxisRStickX = 2, AxisRStickY = 3, - TouchpadX = 6, - TouchpadY = 7 + PointerX = 6, + PointerY = 7, + PointerDeltaX = 8, + PointerDeltaY = 9 } public enum InputVector : int { LStick = 0, RStick = 1, - Touchpad = 2, - Gyroscope = 3, - Accelerometer = 4, + Pointer = 2, + PointerSpeed = 3, + Gyroscope = 4, + Accelerometer = 5, } //D-Pad directions, usable to adapt analogue sticks to cardinal directions @@ -295,7 +298,10 @@ namespace HeavenStudio.InputSystem public abstract bool GetHatDirectionUp(InputDirection direction, out double dt); public abstract bool GetFlick(out double dt); - public abstract bool GetSwipe(out double dt); + public abstract bool GetSlide(out double dt); + public abstract bool GetSqueezeDown(out double dt); + public abstract bool GetSqueezeUp(out double dt); + public abstract bool GetSqueeze(); /// /// Sets the player number (starts at 1, set to -1 or null for no player) diff --git a/Assets/Scripts/InputSystem/PlayerInput.cs b/Assets/Scripts/InputSystem/PlayerInput.cs index acbdc03b2..7e7ce1732 100644 --- a/Assets/Scripts/InputSystem/PlayerInput.cs +++ b/Assets/Scripts/InputSystem/PlayerInput.cs @@ -305,6 +305,36 @@ namespace HeavenStudio return a && PlayerHasControl(); } + public static bool GetSqueeze() + { + bool a = GetInputController(1).GetSqueeze(); + return a && PlayerHasControl(); + } + + public static bool GetSqueezeDown() + { + bool a = GetInputController(1).GetSqueezeDown(out _); + return a && PlayerHasControl(); + } + + public static bool GetSqueezeDown(out double dt) + { + bool a = GetInputController(1).GetSqueezeDown(out dt); + return a && PlayerHasControl(); + } + + public static bool GetSqueezeUp() + { + bool a = GetInputController(1).GetSqueezeUp(out _); + return a && PlayerHasControl(); + } + + public static bool GetSqueezeUp(out double dt) + { + bool a = GetInputController(1).GetSqueezeUp(out dt); + return a && PlayerHasControl(); + } + public static bool GetTouchDown(InputController.ActionsTouch ac, out double dt) { bool a = GetInputController(1).GetActionDown(InputController.ControlStyles.Touch, (int)ac, out dt); @@ -335,15 +365,15 @@ namespace HeavenStudio return a && PlayerHasControl(); } - public static bool GetSwipe() + public static bool GetSlide() { - bool a = GetInputController(1).GetSwipe(out _); + bool a = GetInputController(1).GetSlide(out _); return a && PlayerHasControl(); } - public static bool GetSwipe(out double dt) + public static bool GetSlide(out double dt) { - bool a = GetInputController(1).GetSwipe(out dt); + bool a = GetInputController(1).GetSlide(out dt); return a && PlayerHasControl(); }