From 71792e0a2f322dd11e5a2603382d2d3c548832d0 Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Mon, 26 Jun 2023 14:26:01 +0200 Subject: [PATCH] Basic Roll Cue implemented --- Assets/Resources/Games/nightWalkAgb.prefab | 21 ++++++++- .../Games/NightWalkAgb/AgbNightWalk.cs | 1 + .../Scripts/Games/NightWalkAgb/AgbPlatform.cs | 36 +++++++++++++- .../Scripts/Games/NightWalkAgb/AgbPlayYan.cs | 47 ++++++++++++++++++- 4 files changed, 101 insertions(+), 4 deletions(-) diff --git a/Assets/Resources/Games/nightWalkAgb.prefab b/Assets/Resources/Games/nightWalkAgb.prefab index 628df63ba..9bd780031 100644 --- a/Assets/Resources/Games/nightWalkAgb.prefab +++ b/Assets/Resources/Games/nightWalkAgb.prefab @@ -656,6 +656,7 @@ MonoBehaviour: star: {fileID: 7943729825301934244} randomMinBalloonX: -0.45 randomMaxBalloonX: 0.45 + spriteTrans: {fileID: 3224445989681038566} --- !u!95 &8149215091084911589 Animator: serializedVersion: 5 @@ -958,7 +959,7 @@ MonoBehaviour: useLastRealPos: 0 values: [] - name: Whiff - preview: 1 + preview: 0 anchor: {fileID: 0} positions: - tag: @@ -975,6 +976,24 @@ MonoBehaviour: duration: 0 useLastRealPos: 0 values: [] + - name: highJump + preview: 1 + anchor: {fileID: 0} + positions: + - tag: + pos: {x: 0, y: 2, z: 0} + target: {fileID: 0} + height: 4.5 + duration: 1.5 + useLastRealPos: 0 + values: [] + - tag: + pos: {x: 0, y: 0, z: 0} + target: {fileID: 0} + height: 0 + duration: 0 + useLastRealPos: 0 + values: [] --- !u!1 &4465275889429203320 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Games/NightWalkAgb/AgbNightWalk.cs b/Assets/Scripts/Games/NightWalkAgb/AgbNightWalk.cs index 7f99efda7..76dc4eb68 100644 --- a/Assets/Scripts/Games/NightWalkAgb/AgbNightWalk.cs +++ b/Assets/Scripts/Games/NightWalkAgb/AgbNightWalk.cs @@ -432,6 +432,7 @@ namespace HeavenStudio.Games new MultiSound.Sound("games/nightWalkRvl/highJump2", beat - 0.75), new MultiSound.Sound("games/nightWalkRvl/highJump3", beat - 0.5), new MultiSound.Sound("games/nightWalkRvl/highJump4", beat - 0.25), + new MultiSound.Sound("games/nightWalkRvl/highJump5", beat), }, false, true); } diff --git a/Assets/Scripts/Games/NightWalkAgb/AgbPlatform.cs b/Assets/Scripts/Games/NightWalkAgb/AgbPlatform.cs index 09d9c9419..22dafb882 100644 --- a/Assets/Scripts/Games/NightWalkAgb/AgbPlatform.cs +++ b/Assets/Scripts/Games/NightWalkAgb/AgbPlatform.cs @@ -32,6 +32,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk private bool doFillStartSound = false; private PlayerActionEvent inputEvent; + private PlayerActionEvent releaseEvent; [NonSerialized] public bool stopped; [SerializeField] private GameObject fallYan; [SerializeField] private Animator fish; @@ -60,11 +61,13 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk fish.gameObject.SetActive(isFish); isEndEvent = game.endBeat == endBeat; if (isEndEvent) anim.Play("EndIdle", 0, 0); - isRollPlatform = !isEndEvent && game.RollOnBeat(endBeat); + isRollPlatform = game.RollOnBeat(endBeat); rollPlatform.SetActive(isRollPlatform); if (isRollPlatform) { platform.SetActive(false); + inputEvent = game.ScheduleInput(startBeat, endBeat - startBeat, InputType.STANDARD_ALT_DOWN, JustRollHold, RollMissHold, Empty); + releaseEvent = game.ScheduleInput(startBeat, endBeat - startBeat + 0.5, InputType.STANDARD_ALT_UP, JustRollRelease, RollMissRelease, Empty); } else { @@ -206,6 +209,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk { stopped = true; if (inputEvent != null) inputEvent.Disable(); + if (releaseEvent != null) releaseEvent.Disable(); } public void Disappear(double beat) @@ -230,6 +234,36 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk StartInput(newStartBeat, newStartBeat + (handler.platformCount * 0.5f)); } } + private void JustRollHold(PlayerActionEvent caller, float state) + { + if (state >= 1f || state <= -1f) + { + return; + } + game.playYan.Roll(Conductor.instance.songPositionInBeats); + SoundByte.PlayOneShot("games/nightWalkRvl/highJump6"); + } + + private void JustRollRelease(PlayerActionEvent caller, float state) + { + if (state >= 1f || state <= -1f) + { + return; + } + game.playYan.HighJump(Conductor.instance.songPositionInBeats); + SoundByte.PlayOneShot("games/nightWalkRvl/highJump7"); + } + + private void RollMissHold(PlayerActionEvent caller) + { + + } + + private void RollMissRelease(PlayerActionEvent caller) + { + + } + private void Just(PlayerActionEvent caller, float state) { canKick = false; diff --git a/Assets/Scripts/Games/NightWalkAgb/AgbPlayYan.cs b/Assets/Scripts/Games/NightWalkAgb/AgbPlayYan.cs index e0883515c..c67ff140c 100644 --- a/Assets/Scripts/Games/NightWalkAgb/AgbPlayYan.cs +++ b/Assets/Scripts/Games/NightWalkAgb/AgbPlayYan.cs @@ -16,7 +16,9 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk Shocked, Falling, Whiffing, - Floating + Floating, + Rolling, + HighJumping } private JumpingState jumpingState; private AgbNightWalk game; @@ -25,18 +27,21 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk [SerializeField] private Animator star; private Path jumpPath; private Path whiffPath; + private Path highJumpPath; private Animator anim; private float fallStartY; private double playYanFallBeat; private double walkBeat; [SerializeField] private float randomMinBalloonX = -0.45f; [SerializeField] private float randomMaxBalloonX = 0.45f; + [SerializeField] private Transform spriteTrans; //for rolling rotation private void Awake() { game = AgbNightWalk.instance; jumpPath = game.GetPath("Jump"); whiffPath = game.GetPath("Whiff"); + highJumpPath = game.GetPath("highJump"); anim = GetComponent(); foreach (var balloon in balloons) { @@ -54,7 +59,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk switch (jumpingState) { case JumpingState.Jumping: - Vector3 pos = GetPathPositionFromBeat(jumpPath, Math.Min(jumpBeat + 1, cond.songPositionInBeatsAsDouble), jumpBeat); + Vector3 pos = GetPathPositionFromBeat(jumpPath, Math.Min(jumpBeat + jumpPath.positions[0].duration, cond.songPositionInBeatsAsDouble), jumpBeat); transform.localPosition = pos; float normalizedBeat = cond.GetPositionFromBeat(jumpBeat, jumpPath.positions[0].duration); if (normalizedBeat >= 1f) @@ -96,6 +101,20 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk float newPlayYanYF = funcF(fallStartY, 12, normalizedFloatBeat); transform.localPosition = new Vector3(0, newPlayYanYF); break; + case JumpingState.Rolling: + float normalizedRoll = cond.GetPositionFromBeat(jumpBeat, 0.5f); + float newRot = Mathf.LerpUnclamped(0, -360, normalizedRoll); + spriteTrans.localEulerAngles = new Vector3(0, 0, newRot); + break; + case JumpingState.HighJumping: + Vector3 posH = GetPathPositionFromBeat(highJumpPath, Math.Min(jumpBeat + highJumpPath.positions[0].duration, cond.songPositionInBeatsAsDouble), jumpBeat); + transform.localPosition = posH; + float normalizedBeatH = cond.GetPositionFromBeat(jumpBeat, highJumpPath.positions[0].duration); + if (normalizedBeatH >= 1f) + { + Walk(); + } + break; } } } @@ -105,6 +124,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk jumpingState = JumpingState.Shocked; anim.DoScaledAnimationAsync("Shock", 0.5f); SoundByte.PlayOneShotGame("nightWalkAgb/shock"); + spriteTrans.localEulerAngles = Vector3.zero; } public void Fall(double beat) @@ -114,6 +134,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk playYanFallBeat = beat; fallStartY = transform.localPosition.y; SoundByte.PlayOneShotGame("nightWalkAgb/fall"); + spriteTrans.localEulerAngles = Vector3.zero; Update(); } @@ -125,6 +146,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk fallStartY = transform.localPosition.y; star.gameObject.SetActive(true); StarBlink(); + spriteTrans.localEulerAngles = Vector3.zero; Update(); } @@ -138,16 +160,36 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk jumpingState = JumpingState.Jumping; jumpBeat = beat; anim.Play("Jump", 0, 0); + spriteTrans.localEulerAngles = Vector3.zero; jumpPath.positions[0].duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.earlyTime, Conductor.instance.GetBpmAtBeat(jumpBeat)); Update(); } + public void HighJump(double beat) + { + jumpingState = JumpingState.HighJumping; + jumpBeat = beat; + anim.DoScaledAnimationAsync("HighJump", 0.5f); + spriteTrans.localEulerAngles = Vector3.zero; + highJumpPath.positions[0].duration = 1.5f - (float)Conductor.instance.SecsToBeats(Minigame.earlyTime, Conductor.instance.GetBpmAtBeat(jumpBeat)); + Update(); + } + + public void Roll(double beat) + { + jumpingState = JumpingState.Rolling; + jumpBeat = beat; + anim.DoScaledAnimationAsync("Roll", 0.5f); + Update(); + } + public void Whiff(double beat) { jumpingState = JumpingState.Whiffing; jumpBeat = beat; anim.Play("Jump", 0, 0); SoundByte.PlayOneShotGame("nightWalkAgb/whiff"); + spriteTrans.localEulerAngles = Vector3.zero; Update(); } @@ -156,6 +198,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk if (jumpingState == JumpingState.Walking) return; jumpingState = JumpingState.Walking; walkBeat = Conductor.instance.songPositionInBeats; + spriteTrans.localEulerAngles = Vector3.zero; } public void PopBalloon(int index, bool instant) {