From 7d9e4f10e518b0269a40f58fd6a8f2b96f3a69f1 Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Fri, 14 Jul 2023 15:55:08 +0200 Subject: [PATCH] inputs --- Assets/Resources/Games/animalAcrobat.prefab | 2 +- .../Games/AnimalAcrobat/AcrobatObstacle.cs | 42 +++++++++++++++---- .../Games/AnimalAcrobat/AnimalAcrobat.cs | 8 ++++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Assets/Resources/Games/animalAcrobat.prefab b/Assets/Resources/Games/animalAcrobat.prefab index c37c9e895..5349c8a15 100644 --- a/Assets/Resources/Games/animalAcrobat.prefab +++ b/Assets/Resources/Games/animalAcrobat.prefab @@ -1043,7 +1043,7 @@ MonoBehaviour: elephantStart: 0.004 elephantHangCameraMoveLength: 2 elephantHangMaxDip: 1 - elephantReleaseMoveLength: 6 + elephantReleaseMoveLength: 8.304 giraffeRef: {fileID: 5248028064811562821, guid: 72e69b6337a6bc04f86ffcf5bcedab92, type: 3} giraffeDistance: 0 giraffeStart: 0 diff --git a/Assets/Scripts/Games/AnimalAcrobat/AcrobatObstacle.cs b/Assets/Scripts/Games/AnimalAcrobat/AcrobatObstacle.cs index ffc3bc6f5..cfd11973c 100644 --- a/Assets/Scripts/Games/AnimalAcrobat/AcrobatObstacle.cs +++ b/Assets/Scripts/Games/AnimalAcrobat/AcrobatObstacle.cs @@ -23,11 +23,13 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat private double startBeat = double.MinValue; private float halfAngle; private EasingFunction.Function func; + private AnimalAcrobat game; private void Awake() { halfAngle = fullRotateAngle / 2; func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseInOutQuad); + game = AnimalAcrobat.instance; } public void Init(double beat, double gameSwitchBeat) @@ -53,6 +55,7 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat }), }); } + game.ScheduleInput(beat - 1, 1, InputType.STANDARD_DOWN, JustHold, Empty, Empty); Update(); } @@ -70,17 +73,40 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat float normalizedSwingBeat = cond.GetPositionFromBeat(startBeat, holdLength); float negativeOffset = (normalizedSwingBeat < 0) ? -1 : 0; float normalizedAdjusted = Mathf.Abs(normalizedSwingBeat % 1); - if ((Mathf.Floor(normalizedSwingBeat) + negativeOffset) % 2 == 0) + bool goingRight = (Mathf.Floor(normalizedSwingBeat) + negativeOffset) % 2 == 0; + float dirMult = goingRight ? 1 : -1; + rotatePivot.localEulerAngles = new Vector3(0, 0, func(-halfAngle * dirMult, halfAngle * dirMult, normalizedAdjusted)); + if (type == ObstacleType.Monkeys) anim.DoNormalizedAnimation("WhiteMonkeysSwing", normalizedAdjusted); + } + + private void JustHold(PlayerActionEvent caller, float state) + { + SoundByte.PlayOneShotGame("animalAcrobat/grab"); + game.ScheduleInput(startBeat, holdLength, InputType.STANDARD_UP, JustRelease, Empty, Empty); + } + + private void JustRelease(PlayerActionEvent caller, float state) + { + double beat = caller.startBeat + caller.timer; + switch (type) { - rotatePivot.localEulerAngles = new Vector3(0, 0, func(-halfAngle, halfAngle, normalizedAdjusted)); - if (type == ObstacleType.Monkeys) anim.DoNormalizedAnimation("WhiteMonkeysSwing", normalizedAdjusted); - } - else - { - rotatePivot.localEulerAngles = new Vector3(0, 0, func(halfAngle, -halfAngle, normalizedAdjusted)); - if (type == ObstacleType.Monkeys) anim.DoNormalizedAnimation("WhiteMonkeysSwing", 1 - normalizedAdjusted); + case ObstacleType.Giraffe: + SoundByte.PlayOneShotGame("animalAcrobat/giraffeRelease"); + SoundByte.PlayOneShotGame("animalAcrobat/giraffeReleaseLoop", beat, 1, 1, true).SetLoopParams(beat + 4, 0); + MultiSound.Play(new MultiSound.Sound[] + { + new MultiSound.Sound("animalAcrobat/flip", beat + 3), + new MultiSound.Sound("cymbal", beat + 4) + }); + break; + default: + SoundByte.PlayOneShotGame("animalAcrobat/release"); + SoundByte.PlayOneShotGame("animalAcrobat/flip", beat + 1); + break; } } + + private void Empty(PlayerActionEvent caller) { } } } diff --git a/Assets/Scripts/Games/AnimalAcrobat/AnimalAcrobat.cs b/Assets/Scripts/Games/AnimalAcrobat/AnimalAcrobat.cs index baf771376..3ea2eb18f 100644 --- a/Assets/Scripts/Games/AnimalAcrobat/AnimalAcrobat.cs +++ b/Assets/Scripts/Games/AnimalAcrobat/AnimalAcrobat.cs @@ -119,6 +119,12 @@ namespace HeavenStudio.Games } } + private void StartJump(double beat) + { + SoundByte.PlayOneShotGame("animalAcrobat/beginningLeap", beat); + } + + #region Camera private void CameraMoveUpdate(Conductor cond) { if (movesIndex >= moves.Count) return; @@ -200,6 +206,7 @@ namespace HeavenStudio.Games GameCamera.additionalPosition = new Vector3(newPosX, newPosY, 0); } } + #endregion #region Spawn Animals public override void OnPlay(double beat) @@ -218,6 +225,7 @@ namespace HeavenStudio.Games if (animalEvents.Count == 0) return; animalEvents.Sort((x, y) => x.beat.CompareTo(y.beat)); double nextBeat = animalEvents[0].beat; + StartJump(nextBeat - 1); float startPos = animalEvents[0].datamodel switch { "animalAcrobat/elephant" => elephantStart - elephantDistance,