diff --git a/Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs b/Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs index 2499da7f8..011f88473 100644 --- a/Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs +++ b/Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs @@ -1,4 +1,5 @@ using HeavenStudio.Util; +using HeavenStudio.InputSystem; using System; using System.Collections.Generic; using UnityEngine; @@ -71,7 +72,7 @@ namespace HeavenStudio.Games.Loaders defaultLength = 4f, resizable = true }, - new GameAction("bop", "Bop") + new GameAction("bop", "Bop") { function = delegate {var e = eventCaller.currentEntity; FlipperFlop.instance.Bop(e.beat, e.length, e["whoBops"], e["whoBopsAuto"]); }, resizable = true, @@ -97,9 +98,9 @@ namespace HeavenStudio.Games.Loaders defaultLength = 0.5f } }, - new List() {"ntr", "keep"}, + new List() { "ntr", "keep" }, "rvlseal", "en", - new List() {"en"} + new List() { "en" } ); } } @@ -132,6 +133,7 @@ namespace HeavenStudio.Games float lastCameraXPos; float currentCameraXPos; bool isWalking; + bool readyRoll; public GameEvent bop = new GameEvent(); bool goBopFlip; bool goBopTuck; @@ -182,6 +184,34 @@ namespace HeavenStudio.Games } public static FlipperFlop instance; + const int IAAltDownCat = 4; + + protected static bool IA_TouchPress(out double dt) + { + return PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt) + && (instance.IsExpectingInputNow(InputAction_Nrm) || !(instance.IsExpectingInputNow(InputAction_Alt) || instance.readyRoll)); + } + + 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.GetSlide(out dt); + } + + public static PlayerInput.InputAction InputAction_Alt = + new("RvlSealAlt", new int[] { IAAltDownCat, IAAltDownCat, IAAltDownCat }, + IA_PadAltPress, IA_TouchAltPress, IA_BatonAltPress); + public static PlayerInput.InputAction InputAction_Nrm = + new("RvlSealNrm", new int[] { IAPressCat, IAPressCat, IAPressCat }, + IA_PadBasicPress, IA_TouchPress, IA_BatonBasicPress); + void Awake() { instance = this; @@ -203,7 +233,7 @@ namespace HeavenStudio.Games private void Update() { var cond = Conductor.instance; - if(cond.isPlaying && !cond.isPaused) + if (cond.isPlaying && !cond.isPaused) { if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1)) { @@ -221,14 +251,14 @@ namespace HeavenStudio.Games isWalking = false; } } - if ((PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN)) || (PlayerInput.AltPressed() && !IsExpectingInputNow(InputType.STANDARD_ALT_DOWN))) + if ((PlayerInput.GetIsAction(InputAction_Nrm) && !IsExpectingInputNow(InputAction_Nrm)) || (PlayerInput.GetIsAction(InputAction_Alt) && !IsExpectingInputNow(InputAction_Alt))) { flipperPlayer.Flip(false, false, false, true); } if (queuedInputs.Count > 0) { - foreach (var input in queuedInputs) - { + foreach (var input in queuedInputs) + { QueueFlips(input.beat, input.length, input.roll, input.uh, input.thatsIt, input.appreciation, input.heart, input.thatsItBarberShop); } queuedInputs.Clear(); @@ -301,7 +331,7 @@ namespace HeavenStudio.Games public void ToggleTuck() { - captainTuckAnim.gameObject.SetActive(!captainTuckAnim.gameObject.active); + captainTuckAnim.gameObject.SetActive(!captainTuckAnim.gameObject.activeSelf); } public void BumpIntoOtherSeal(bool toTheLeft) @@ -408,11 +438,12 @@ namespace HeavenStudio.Games { if (roll) { - ScheduleInput(beat - 1, 1 + i, InputType.STANDARD_ALT_DOWN, JustFlipperRoll, MissFlipperRoll, Nothing); + ScheduleInput(beat - 1, 1 + i, InputAction_Alt, JustFlipperRoll, MissFlipperRoll, Nothing); queuedMovements.Add(beat + i); BeatAction.New(instance, new List() { - new BeatAction.Action(beat + i - 0.5f, delegate { moveLeft = flippers[0].left;}) + new BeatAction.Action(beat + i - NgEarlyTime() - 1.5, delegate { readyRoll = true; }), + new BeatAction.Action(beat + i - 0.5, delegate { moveLeft = flippers[0].left; readyRoll = true; }), }); foreach (var flipper in flippers) { @@ -469,9 +500,9 @@ namespace HeavenStudio.Games SoundByte.PlayOneShotGame("flipperFlop/appreciation/thatsit1"); captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.5f); }), - new BeatAction.Action(beat + i, delegate - { - SoundByte.PlayOneShotGame("flipperFlop/appreciation/thatsit2"); + new BeatAction.Action(beat + i, delegate + { + SoundByte.PlayOneShotGame("flipperFlop/appreciation/thatsit2"); captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.5f); SoundByte.PlayOneShotGame(soundToPlay); captainTuckAnim.DoScaledAnimationAsync("CaptainBop", 0.5f); @@ -500,7 +531,7 @@ namespace HeavenStudio.Games } CaptainTuckBop(); - SoundByte.PlayOneShotGame(voiceLine); + SoundByte.PlayOneShotGame(voiceLine); }), }); } @@ -556,7 +587,11 @@ namespace HeavenStudio.Games } else { - ScheduleInput(beat - 1, 1 + i, InputType.STANDARD_DOWN, JustFlip, MissFlip, Nothing); + ScheduleInput(beat - 1, 1 + i, InputAction_Nrm, JustFlip, MissFlip, Nothing); + BeatAction.New(instance, new List() + { + new BeatAction.Action(beat + i - NgEarlyTime() - 1, delegate { readyRoll = false; }), + }); foreach (var flipper in flippers) { BeatAction.New(instance, new List() @@ -566,6 +601,13 @@ namespace HeavenStudio.Games } } } + if (roll) + { + BeatAction.New(instance, new List() + { + new BeatAction.Action(beat + length + NgLateTime() - 1, delegate { readyRoll = false; }), + }); + } if (uh > 0 && flopCount != 4) { for (int i = 0; i < uh; i++) @@ -579,7 +621,7 @@ namespace HeavenStudio.Games new BeatAction.Action(beat + length + i, delegate { string voiceLineToPlay = voiceLine; string failVoiceLineToPlay = failVoiceLine; - if (missed) + if (missed) { voiceLineToPlay = failVoiceLineToPlay; currentCaptainBop = CaptainTuckBopType.Miss; @@ -592,14 +634,14 @@ namespace HeavenStudio.Games } CaptainTuckBop(); - SoundByte.PlayOneShotGame(voiceLineToPlay); + SoundByte.PlayOneShotGame(voiceLineToPlay); }), }); } BeatAction.New(instance, new List() { - new BeatAction.Action(beat + length + uh, delegate - { + new BeatAction.Action(beat + length + uh, delegate + { AppreciationVoiceLine(beat + length + uh, appreciation, heart); if (!missed && appreciation != (int)AppreciationType.None) { @@ -611,7 +653,7 @@ namespace HeavenStudio.Games captainTuckFaceAnim.Play("CaptainTuckNeutralExpression", 0, 0); } CaptainTuckBop(); - missed = false; + missed = false; }), new BeatAction.Action(beat + length + uh + 1f, delegate { @@ -765,9 +807,9 @@ namespace HeavenStudio.Games new MultiSound.Sound("flipperFlop/ding", beat + 1f), }, forcePlay: true); - ScheduleInput(beat, 2, InputType.STANDARD_DOWN, JustFlip, MissFlip, Nothing); - ScheduleInput(beat, 2.5f, InputType.STANDARD_DOWN, JustFlip, MissFlip, Nothing); - ScheduleInput(beat, 3, InputType.STANDARD_DOWN, JustFlip, MissFlip, Nothing); + ScheduleInput(beat, 2, InputAction_Nrm, JustFlip, MissFlip, Nothing); + ScheduleInput(beat, 2.5f, InputAction_Nrm, JustFlip, MissFlip, Nothing); + ScheduleInput(beat, 3, InputAction_Nrm, JustFlip, MissFlip, Nothing); foreach (var flipper in flippers) { BeatAction.New(instance, new List() @@ -779,6 +821,7 @@ namespace HeavenStudio.Games } BeatAction.New(instance, new List() { + new BeatAction.Action(beat + 3 - NgEarlyTime(), delegate {readyRoll = false; }), new BeatAction.Action(beat + 2, delegate {captainTuckAnim.DoScaledAnimationAsync("CaptainBop", 0.5f); }), new BeatAction.Action(beat + 3, delegate {captainTuckAnim.DoScaledAnimationAsync("CaptainBop", 0.5f); }), }); @@ -823,9 +866,9 @@ namespace HeavenStudio.Games new BeatAction.Action(beat - 0.25f, delegate { captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.5f); }), new BeatAction.Action(beat, delegate { captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.5f); }), new BeatAction.Action(beat + 0.5f, delegate { captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.0625f); }), - new BeatAction.Action(beat + 2f, delegate - { - captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.5f); + new BeatAction.Action(beat + 2f, delegate + { + captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.5f); if (remix5) { foreach (var flipper in flippers) @@ -837,7 +880,7 @@ namespace HeavenStudio.Games }), new BeatAction.Action(beat + 2.25f, delegate { captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.5f); }), new BeatAction.Action(beat + 2.5f, delegate { captainTuckFaceAnim.DoScaledAnimationAsync("CaptainTuckSpeakExpression", 0.5f); }), - new BeatAction.Action(beat + 3f, delegate + new BeatAction.Action(beat + 3f, delegate { if (remix5) return; foreach (var flipper in flippers) @@ -1082,6 +1125,6 @@ namespace HeavenStudio.Games missed = true; } - public void Nothing(PlayerActionEvent caller) {} + public void Nothing(PlayerActionEvent caller) { } } } diff --git a/Assets/Scripts/Games/MarchingOrders/MarchingOrders.cs b/Assets/Scripts/Games/MarchingOrders/MarchingOrders.cs index 04eda3b39..da4cf7ec0 100644 --- a/Assets/Scripts/Games/MarchingOrders/MarchingOrders.cs +++ b/Assets/Scripts/Games/MarchingOrders/MarchingOrders.cs @@ -1,18 +1,6 @@ -//notes: -// BEFORE NEW PROPS -// - minenice will also use this to test out randomly named parameters so coding has to rest until the new props update [DONE] -// - see fan club for separate prefabs (cadets) [DONE] -// - temporarily take sounds from rhre, wait until someone records the full code, including misses, or record it myself (unlikely) [IN PROGRESS] -// AFTER NEW PROPS -// - testmod marching orders using speed -// - see space soccer, mr upbeat, tunnel for keep-the-beat codes -// - figure how to do custom bg changes when the upscaled textures are finished (see karate man, launch party once it releases) -// - will use a textbox without going through the visual options but i wonder how..?? (see first contact if ever textboxes are implemented in said minigame) -// AFTER FEATURE COMPLETION -// - delete all notes once the minigame is considered feature-complete - using HeavenStudio.Common; using HeavenStudio.Util; +using HeavenStudio.InputSystem; using System; using System.Collections.Generic; using UnityEditor; @@ -110,9 +98,9 @@ namespace HeavenStudio.Games.Loaders }, new GameAction("faceTurnFast", "Fast Face Turn") { - function = delegate { - var e = eventCaller.currentEntity; - MarchingOrders.instance.FaceTurn(e.beat, e["direction"], true, e["point"]); + function = delegate { + var e = eventCaller.currentEntity; + MarchingOrders.instance.FaceTurn(e.beat, e["direction"], true, e["point"]); }, defaultLength = 3f, parameters = new List() @@ -162,7 +150,7 @@ namespace HeavenStudio.Games.Loaders new Param("colorConveyor2", new Color(0.55f, 0.57f, 0.04f), "Conveyor Trim Color", "Sets the conveyor's trim color"), } }, - + new GameAction("forceMarching", "Force Marching") { preFunction = delegate { @@ -229,7 +217,6 @@ namespace HeavenStudio.Games double lastMissBeat; double lastReportedBeat; public static double wantMarch = double.MinValue; - public enum Direction { @@ -250,18 +237,76 @@ namespace HeavenStudio.Games Custom, } + const int IAAltDownCat = 4; + const int IALeft = 5; + const int IARight = 6; + protected static bool IA_PadLeft(out double dt) + { + return PlayerInput.GetPadDown(InputController.ActionsPad.Left, out dt); + } + protected static bool IA_BatonLeft(out double dt) + { + return PlayerInput.GetBatonDown(InputController.ActionsBaton.West, out dt); + } + protected static bool IA_TouchLeft(out double dt) + { + return PlayerInput.GetTouchDown(InputController.ActionsTouch.Left, out dt) + && (instance.IsExpectingInputNow(InputAction_Left) || instance.IsExpectingInputNow(InputAction_Right)); + } + + protected static bool IA_PadRight(out double dt) + { + return PlayerInput.GetPadDown(InputController.ActionsPad.Right, out dt); + } + protected static bool IA_BatonRight(out double dt) + { + return PlayerInput.GetBatonDown(InputController.ActionsBaton.East, out dt); + } + protected static bool IA_TouchRight(out double dt) + { + return PlayerInput.GetTouchDown(InputController.ActionsTouch.Right, out dt) + && (instance.IsExpectingInputNow(InputAction_Left) || instance.IsExpectingInputNow(InputAction_Right)); + } + + protected static bool IA_TouchAltPress(out double dt) + { + return PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt) + && instance.IsExpectingInputNow(InputAction_Alt); + } + 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); + } + + public static PlayerInput.InputAction InputAction_Left = + new("AgbMarcherLeft", new int[] { IALeft, IALeft, IALeft }, + IA_PadLeft, IA_TouchLeft, IA_BatonLeft); + + public static PlayerInput.InputAction InputAction_Right = + new("AgbMarcherRight", new int[] { IARight, IARight, IARight }, + IA_PadRight, IA_TouchRight, IA_BatonRight); + + public static PlayerInput.InputAction InputAction_Alt = + new("AgbMarcherAlt", new int[] { IAAltDownCat, IAAltDownCat, IAAltDownCat }, + IA_PadAltPress, IA_TouchAltPress, IA_BatonAltPress); + void Awake() { instance = this; - + for (int i = 0; i < BackgroundRecolorable.Length; i++) BackgroundRecolorable[i].color = i == 0 ? BGColor1 : BGColor2; } void Update() { for (int i = 0; i < BackgroundRecolorable.Length; i++) BackgroundRecolorable[i].color = i == 0 ? BGColor1 : BGColor2; - - if (wantMarch != double.MinValue) { + + if (wantMarch != double.MinValue) + { queuedMarches.Add(wantMarch); marchOtherCount = marchPlayerCount = 0; @@ -269,17 +314,21 @@ namespace HeavenStudio.Games wantMarch = double.MinValue; } - if (goBop && Conductor.instance.ReportBeat(ref lastReportedBeat)) { + if (goBop && Conductor.instance.ReportBeat(ref lastReportedBeat)) + { foreach (var cadet in Cadets) cadet.DoScaledAnimationAsync(shouldClap ? "Clap" : "Bop", 0.5f); CadetPlayer.DoScaledAnimationAsync(shouldClap ? "Clap" : "Bop", 0.5f); } - if (Conductor.instance.isPlaying && !Conductor.instance.isPaused) { - if (queuedMarches.Count > 0) { - foreach (var march in queuedMarches) { + if (Conductor.instance.isPlaying && !Conductor.instance.isPaused) + { + if (queuedMarches.Count > 0) + { + foreach (var march in queuedMarches) + { BeatAction.New(instance, new List() { new BeatAction.Action(march, delegate { - ScheduleInput(march, 1f, InputType.STANDARD_DOWN, MarchHit, GenericMiss, Empty); + ScheduleInput(march, 1f, InputAction_BasicPress, MarchHit, GenericMiss, Empty); }), new BeatAction.Action(march + 1, delegate { marchOtherCount++; @@ -293,7 +342,8 @@ namespace HeavenStudio.Games } } - if (ConveyorGo[0].AutoScroll && (ConveyorGo[1].gameObject.transform.position.x < 0)) { + if (ConveyorGo[0].AutoScroll && (ConveyorGo[1].gameObject.transform.position.x < 0)) + { foreach (var scroll in ConveyorGo) scroll.AutoScroll = false; ConveyorGo[0].gameObject.transform.position = new Vector3(6.181f, -3.37f); ConveyorGo[1].gameObject.transform.position = new Vector3(0, 0); @@ -301,23 +351,41 @@ namespace HeavenStudio.Games // input stuff below - if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN)) { - Miss(); - marchPlayerCount++; - CadetPlayer.DoScaledAnimationAsync((marchPlayerCount % 2 != 0 ? "MarchR" : "MarchL"), 0.5f); + if (PlayerInput.GetIsAction(InputAction_BasicPress) && !IsExpectingInputNow(InputAction_BasicPress)) + { + if (PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch) + { + if (!(IsExpectingInputNow(InputAction_Alt) + || IsExpectingInputNow(InputAction_Left) + || IsExpectingInputNow(InputAction_Right))) + { + Miss(); + marchPlayerCount++; + CadetPlayer.DoScaledAnimationAsync(marchPlayerCount % 2 != 0 ? "MarchR" : "MarchL", 0.5f); + } + } + else + { + Miss(); + marchPlayerCount++; + CadetPlayer.DoScaledAnimationAsync(marchPlayerCount % 2 != 0 ? "MarchR" : "MarchL", 0.5f); + } } - if (PlayerInput.AltPressed() && !IsExpectingInputNow(InputType.STANDARD_ALT_DOWN)) { + if (PlayerInput.GetIsAction(InputAction_Alt) && !IsExpectingInputNow(InputAction_Alt)) + { Miss(); CadetPlayer.DoScaledAnimationAsync("Halt", 0.5f); } - if (PlayerInput.GetSpecificDirectionDown((int) InputSystem.InputController.InputDirection.Left) && !IsExpectingInputNow(InputType.DIRECTION_LEFT_DOWN)) { + if (PlayerInput.GetIsAction(InputAction_Left) && !IsExpectingInputNow(InputAction_Left)) + { Miss(); CadetHeadPlayer.DoScaledAnimationAsync("FaceL", 0.5f); } - if (PlayerInput.GetSpecificDirectionDown((int) InputSystem.InputController.InputDirection.Right) && !IsExpectingInputNow(InputType.DIRECTION_RIGHT_DOWN)) { + if (PlayerInput.GetIsAction(InputAction_Right) && !IsExpectingInputNow(InputAction_Right)) + { Miss(); CadetHeadPlayer.DoScaledAnimationAsync("FaceR", 0.5f); } @@ -348,8 +416,8 @@ namespace HeavenStudio.Games if (state <= -1f || state >= 1f) SoundByte.PlayOneShot("nearMiss"); else SoundByte.PlayOneShotGame("marchingOrders/turnActionPlayer"); - CadetHeadPlayer.DoScaledAnimationAsync("Face"+dir, 0.5f); - if (shouldPoint) CadetPlayer.DoScaledAnimationAsync("Point"+dir, 0.5f); + CadetHeadPlayer.DoScaledAnimationAsync("Face" + dir, 0.5f); + if (shouldPoint) CadetPlayer.DoScaledAnimationAsync("Point" + dir, 0.5f); } public void GenericMiss(PlayerActionEvent caller) @@ -378,7 +446,7 @@ namespace HeavenStudio.Games { if (state <= -1f || state >= 1f) SoundByte.PlayOneShot("nearMiss"); else SoundByte.PlayOneShotGame("marchingOrders/stepPlayer", volume: 0.25f); - + CadetPlayer.DoScaledAnimationAsync("Halt", 0.5f); } @@ -386,8 +454,10 @@ namespace HeavenStudio.Games { goBop = autoBop; shouldClap = clap; - if (shouldBop) { - for (int i = 0; i < length; i++) { + if (shouldBop) + { + for (int i = 0; i < length; i++) + { BeatAction.New(instance, new List() { new BeatAction.Action(beat + i, delegate { foreach (var cadet in Cadets) cadet.DoScaledAnimationAsync(shouldClap ? "Clap" : "Bop", 0.5f); @@ -404,13 +474,14 @@ namespace HeavenStudio.Games new BeatAction.Action(beat + 0.25f, delegate { Sarge.DoScaledAnimationAsync("Talk", 0.5f);}), }); } - + public static void SargeMarch(double beat, bool noVoice, bool march) { if (march) MarchingOrders.wantMarch = beat + 1; if (!noVoice) PlaySoundSequence("marchingOrders", "susume", beat); - if (GameManager.instance.currentGame == "marchingOrders") { + if (GameManager.instance.currentGame == "marchingOrders") + { MarchingOrders.instance.PreMarch(beat); if (!noVoice) MarchingOrders.instance.Sarge.DoScaledAnimationAsync("Talk", 0.5f); } @@ -418,8 +489,9 @@ namespace HeavenStudio.Games public void ForceMarching(double beat, float length) { - for (int i = 0; i < length; i++) { - ScheduleInput(beat + i - 0.2f, 0.2f, InputType.STANDARD_DOWN, MarchHit, GenericMiss, Empty); + for (int i = 0; i < length; i++) + { + ScheduleInput(beat + i - 0.2f, 0.2f, InputAction_BasicPress, MarchHit, GenericMiss, Empty); BeatAction.New(instance, new List() { new BeatAction.Action(beat + i, delegate { marchOtherCount++; @@ -434,68 +506,69 @@ namespace HeavenStudio.Games { BeatAction.New(this, new List() { - new BeatAction.Action(beat + 1f, delegate { + new BeatAction.Action(beat + 1f, delegate { foreach (var cadet in Cadets) cadet.DoScaledAnimationAsync("MarchL", 0.5f); CadetPlayer.DoScaledAnimationAsync("MarchL", 0.5f); }), }); } - + public void Halt(double beat) { keepMarching = false; - HaltSound(beat); + HaltSound(beat); - ScheduleInput(beat, 1f, InputType.STANDARD_ALT_DOWN, HaltHit, GenericMiss, Empty); - BeatAction.New(this, new List() + ScheduleInput(beat, 1f, InputAction_Alt, HaltHit, GenericMiss, Empty); + BeatAction.New(this, new List() { new BeatAction.Action(beat, delegate { Sarge.DoScaledAnimationAsync("Talk", 0.5f);}), new BeatAction.Action(beat + 1f, delegate { foreach (var cadet in Cadets) cadet.DoScaledAnimationAsync("Halt", 0.5f);}), }); } - + public void FaceTurn(double beat, int direction, bool isFast, bool shouldPoint) { // x is true if the direction is right bool x = (direction == 0); int turnLength = (isFast ? 0 : 1); - ScheduleInput(beat, turnLength + 2f, x ? InputType.DIRECTION_RIGHT_DOWN : InputType.DIRECTION_LEFT_DOWN, x ? (shouldPoint ? RightPointSuccess : RightSuccess) : (shouldPoint ? LeftPointSuccess : LeftSuccess), GenericMiss, Empty); + ScheduleInput(beat, turnLength + 2f, x ? InputAction_Right : InputAction_Left, x ? (shouldPoint ? RightPointSuccess : RightSuccess) : (shouldPoint ? LeftPointSuccess : LeftSuccess), GenericMiss, Empty); MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound($"marchingOrders/{(x ? "right" : "left")}FaceTurn1{(isFast ? "fast" : "")}", beat), new MultiSound.Sound($"marchingOrders/{(x ? "right" : "left")}FaceTurn2{(isFast ? "fast" : "")}", beat + 0.5f), new MultiSound.Sound($"marchingOrders/{(x ? "right" : "left")}FaceTurn3", beat + turnLength + 1f), new MultiSound.Sound("marchingOrders/turnAction", beat + turnLength + 2f), }, forcePlay: true); - + BeatAction.New(this, new List() { new BeatAction.Action(beat + turnLength + 2f,delegate { if (shouldPoint) foreach (var cadet in Cadets) cadet.DoScaledAnimationAsync($"Point{(x ? "R" : "L")}", 0.5f); foreach (var head in CadetHeads) head.DoScaledAnimationAsync($"Face{(x ? "R" : "L")}", 0.5f); }) }); - - BeatAction.New(this, new List() + + BeatAction.New(this, new List() { new BeatAction.Action(beat, delegate { Sarge.DoScaledAnimationAsync("Talk", 0.5f);}), new BeatAction.Action(beat + turnLength + 1f, delegate { Sarge.DoScaledAnimationAsync("Talk", 0.5f);}), }); } - + public void BackgroundColorSet(int preset, Color fill, Color tiles1, Color tiles2, Color tiles3, Color pipes1, Color pipes2, Color pipes3, Color conveyor1, Color conveyor2) { if (preset == 2) UpdateMaterialColor(fill, tiles1, tiles2, tiles3, pipes1, pipes2, pipes3, conveyor1, conveyor2); - else { + else + { bool x = preset == 0; UpdateMaterialColor( x ? new Color(0.26f, 0.36f, 0.39f) : new Color(0.25f, 0.45f, 0.52f), - x ? new Color(1f, 0.76f, 0.52f) : new Color(0.45f, 0.71f, 0.81f), - x ? new Color(1f, 0.6f, 0.2f) : new Color(0.65f, 0.87f, 0.94f), - x ? new Color(1f, 0.68f, 0f) : new Color(0.65f, 0.87f, 0.94f), + x ? new Color(1f, 0.76f, 0.52f) : new Color(0.45f, 0.71f, 0.81f), + x ? new Color(1f, 0.6f, 0.2f) : new Color(0.65f, 0.87f, 0.94f), + x ? new Color(1f, 0.68f, 0f) : new Color(0.65f, 0.87f, 0.94f), x ? new Color(0.41f, 0.54f, 0.34f) : new Color(0.36f, 0.58f, 0.64f), - x ? new Color(0.43f, 0.8f, 0.45f) : new Color(0.48f, 0.65f, 0.71f), + x ? new Color(0.43f, 0.8f, 0.45f) : new Color(0.48f, 0.65f, 0.71f), x ? new Color(0.48f, 0.89f, 0.54f) : new Color(0.48f, 0.65f, 0.71f), - x ? new Color(0.16f, 0.25f, 0.3f) : new Color(0.32f, 0.55f, 0.62f), + x ? new Color(0.16f, 0.25f, 0.3f) : new Color(0.32f, 0.55f, 0.62f), x ? new Color(0.55f, 0.57f, 0.04f) : new Color(0.17f, 0.31f, 0.35f) ); } @@ -510,7 +583,8 @@ namespace HeavenStudio.Games Recolor(1, pipes2, pipes1, pipes3); Recolor(2, new Color(0, 0, 0), conveyor1, conveyor2); - void Recolor(int i, Color color1, Color color2, Color color3) { + void Recolor(int i, Color color1, Color color2, Color color3) + { RecolorMats[i].SetColor("_ColorAlpha", color1); RecolorMats[i].SetColor("_ColorBravo", color2); RecolorMats[i].SetColor("_ColorDelta", color3); @@ -521,7 +595,7 @@ namespace HeavenStudio.Games { PlaySoundSequence("marchingOrders", "zentai", beat - 1); } - + public static void HaltSound(double beat) { PlaySoundSequence("marchingOrders", "tomare", beat); @@ -529,8 +603,9 @@ namespace HeavenStudio.Games public void MoveConveyor(float length, bool go, int direction) { - foreach (var scroll in ConveyorGo) { - scroll.SpeedMod = ((direction == 0 ? 20 : -20)/length)*(Conductor.instance.songBpm/100); + foreach (var scroll in ConveyorGo) + { + scroll.SpeedMod = ((direction == 0 ? 20 : -20) / length) * (Conductor.instance.songBpm / 100); scroll.AutoScroll = go; } } diff --git a/Assets/Scripts/Games/SpaceSoccer/Kicker.cs b/Assets/Scripts/Games/SpaceSoccer/Kicker.cs index 1f10465de..cf18e077b 100644 --- a/Assets/Scripts/Games/SpaceSoccer/Kicker.cs +++ b/Assets/Scripts/Games/SpaceSoccer/Kicker.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using UnityEngine; using HeavenStudio.Util; +using HeavenStudio.InputSystem; namespace HeavenStudio.Games.Scripts_SpaceSoccer { @@ -54,7 +55,7 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer { if (player) { - nextHit = game.ScheduleInput(beat, ball.GetAnimLength(Ball.State.Dispensing), InputType.STANDARD_DOWN, KickJust, Miss, Out); + nextHit = game.ScheduleInput(beat, ball.GetAnimLength(Ball.State.Dispensing), SpaceSoccer.InputAction_BasicPress, KickJust, Miss, Out); } else { @@ -193,7 +194,7 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer } - public void Toe(bool hit) + public void Toe(bool hit, bool flick = false) { if (stopBall) return; if (kickLeft) @@ -217,8 +218,11 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer if (hit && ball) ball.Toe(); - kickTimes++; - kickPrepare = false; + if (!flick) + { + kickTimes++; + kickPrepare = false; + } } private void Update() @@ -265,7 +269,8 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer if (player) { if (stopBall) return; - if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN)) + if (PlayerInput.GetIsAction(SpaceSoccer.InputAction_BasicPress) + && !game.IsExpectingInputNow(SpaceSoccer.InputAction_BasicPress)) { if (ball == null) KickCheck(false, true); @@ -273,16 +278,26 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer Kick(false, ball.canKick); } - if (PlayerInput.PressedUp() && ball != null) + if (PlayerInput.GetIsAction(SpaceSoccer.InputAction_FlickRelease)) { - if (ball.waitKickRelease) + if (PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch) { - ball.waitKickRelease = false; + if (ball == null || !(game.IsExpectingInputNow(SpaceSoccer.InputAction_FlickRelease) || ball.canKick)) + { + Toe(false); + } } - else if (ball.canKick && !game.IsExpectingInputNow(InputType.STANDARD_UP)) + if (ball != null) { - ball.canKick = false; - Kick(false); + if (ball.waitKickRelease) + { + ball.waitKickRelease = false; + } + else if (ball.canKick && !game.IsExpectingInputNow(SpaceSoccer.InputAction_FlickRelease)) + { + ball.canKick = false; + Kick(false); + } } } } @@ -359,15 +374,15 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer if (canHighKick) { // queue high kick inputs - nextHit = game.ScheduleInput(caller.startBeat + caller.timer, ball.GetAnimLength(Ball.State.Toe), InputType.STANDARD_UP, ToeJust, Miss, Out); - nextAutoKick = game.ScheduleAutoplayInput(caller.startBeat + caller.timer, ball.GetAnimLength(Ball.State.Kicked), InputType.STANDARD_DOWN, ToePrepareJust, Out, Out); + nextHit = game.ScheduleInput(caller.startBeat + caller.timer, ball.GetAnimLength(Ball.State.Toe), SpaceSoccer.InputAction_FlickRelease, ToeJust, Miss, Out); + nextAutoKick = game.ScheduleAutoplayInput(caller.startBeat + caller.timer, ball.GetAnimLength(Ball.State.Kicked), SpaceSoccer.InputAction_BasicPress, ToePrepareJust, Out, Out); ball.canKick = true; ball.waitKickRelease = true; } else { // queue normal kick input - nextHit = game.ScheduleInput(caller.startBeat + caller.timer, ball.GetAnimLength(Ball.State.Kicked), InputType.STANDARD_DOWN, KickJust, Miss, Out); + nextHit = game.ScheduleInput(caller.startBeat + caller.timer, ball.GetAnimLength(Ball.State.Kicked), SpaceSoccer.InputAction_BasicPress, KickJust, Miss, Out); } } @@ -390,7 +405,7 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer return; } Toe(true); - nextHit = game.ScheduleInput(caller.startBeat, 3f, InputType.STANDARD_DOWN, KickJust, Miss, Out); + nextHit = game.ScheduleInput(caller.startBeat, 3f, SpaceSoccer.InputAction_BasicPress, KickJust, Miss, Out); ball.canKick = false; } diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs index 3edcbd252..938f0c176 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs @@ -35,9 +35,10 @@ namespace HeavenStudio.InputSystem { public class InputMouse : InputController { - const double FlickMarginTime = 0.05; - const double BigMoveMarginSpd = 0.1; - const double SmallMoveMarginSpd = 0.025; + const double SlideMarginTime = 0.25; + const double BigMoveMarginSpd = 0.15; + const double SmallMoveMarginSpd = 0.02; + const double SlideDist = 0.75; private static readonly KeyCode[] keyCodes = Enum.GetValues(typeof(KeyCode)) .Cast() @@ -79,7 +80,7 @@ namespace HeavenStudio.InputSystem Vector3 deltaPointerPos, lastDeltaPointerPos; double timeMoveChange, timeDirectionChange; byte dirLeftRight, dirUpDown; - bool hasFlicked, hasSwiped, isInMove; + bool hasFlicked, hasSwiped, isInMove, isInSwipe; public override void InitializeController() { @@ -107,36 +108,40 @@ namespace HeavenStudio.InputSystem // Debug.Log($"pointer speed: {deltaPointerPos.magnitude}, direction: {deltaPointerPos.normalized}"); if (speed >= BigMoveMarginSpd) { - timeMoveChange = Time.realtimeSinceStartupAsDouble; if (!isInMove) { isInMove = true; + } + if ((!isInSwipe) + && (Time.realtimeSinceStartupAsDouble - timeMoveChange <= SlideMarginTime) + && (realPos - startPointerPos).magnitude > SlideDist) + { hasSwiped = true; - // Debug.Log($"just started moving or direction change"); + isInSwipe = true; + Debug.Log($"swipe (speed: {speed})"); } } else { - if (isInMove && speed < SmallMoveMarginSpd) + if (speed < SmallMoveMarginSpd) { - // Debug.Log($"just stopped moving"); + timeMoveChange = Time.realtimeSinceStartupAsDouble; isInMove = false; + isInSwipe = false; + startPointerPos = realPos; } } } - double dMoveChange = Time.realtimeSinceStartupAsDouble - timeMoveChange; if (GetActionUp(ControlStyles.Touch, 0, out double dt)) { isInMove = false; + isInSwipe = false; lastRawPointerPos = rawPointerPos; lastRealPos = realPos; + startPointerPos = realPos; lastDeltaPointerPos = deltaPointerPos; - hasFlicked = dMoveChange < FlickMarginTime && speed >= BigMoveMarginSpd; - // if (hasFlicked) - // { - // Debug.Log($"flicked (speed: {dMoveChange})"); - // } + hasFlicked = speed >= BigMoveMarginSpd; } }