From f2a3ef03c9e16003a205d966d2bc0d8f9da3abee Mon Sep 17 00:00:00 2001 From: fu-majime Date: Sun, 7 Apr 2024 22:16:18 +0900 Subject: [PATCH] Refactoring failed --- Assets/Resources/Games/frogPrincess.prefab | 46 +-- .../Games/FrogPrincess/FrogPrincess.cs | 317 +++++++++--------- 2 files changed, 164 insertions(+), 199 deletions(-) diff --git a/Assets/Resources/Games/frogPrincess.prefab b/Assets/Resources/Games/frogPrincess.prefab index 4809d8f08..375400d85 100644 --- a/Assets/Resources/Games/frogPrincess.prefab +++ b/Assets/Resources/Games/frogPrincess.prefab @@ -2171,7 +2171,7 @@ ParticleSystem: donutRadius: 0.2 m_Position: {x: 0, y: 0, z: 0} m_Rotation: {x: 0, y: 0, z: 0} - m_Scale: {x: 1, y: 1, z: 1} + m_Scale: {x: 1, y: 0, z: 1} placementMode: 0 m_MeshMaterialIndex: 0 m_MeshNormalOffset: 0 @@ -6731,10 +6731,6 @@ PrefabInstance: propertyPath: m_Name value: leafs (4) objectReference: {fileID: 0} - - target: {fileID: 3324563509541492245, guid: db186a9c93598ed49b6d45d6135a38bf, type: 3} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - target: {fileID: 3697501304178671121, guid: db186a9c93598ed49b6d45d6135a38bf, type: 3} propertyPath: m_RootOrder value: 3 @@ -6859,10 +6855,6 @@ PrefabInstance: propertyPath: m_Name value: leafs (3) objectReference: {fileID: 0} - - target: {fileID: 3324563509541492245, guid: db186a9c93598ed49b6d45d6135a38bf, type: 3} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - target: {fileID: 3697501304178671121, guid: db186a9c93598ed49b6d45d6135a38bf, type: 3} propertyPath: m_RootOrder value: 2 @@ -6983,42 +6975,6 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 4337885411777812744} m_Modifications: - - target: {fileID: 3047306057988244668, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalPosition.x - value: -0.38 - objectReference: {fileID: 0} - - target: {fileID: 3047306057988244668, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalPosition.y - value: -2.3 - objectReference: {fileID: 0} - - target: {fileID: 5608574033249632159, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalPosition.x - value: -0.192 - objectReference: {fileID: 0} - - target: {fileID: 5608574033249632159, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalPosition.y - value: -4.65 - objectReference: {fileID: 0} - - target: {fileID: 5608574033249632159, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5608574033249632159, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 5608574033249632159, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 5608574033249632159, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 5608574033249632159, guid: a195026c0abb13b47b49c10d3217c559, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - target: {fileID: 7392517377544777057, guid: a195026c0abb13b47b49c10d3217c559, type: 3} propertyPath: m_RootOrder value: 1 diff --git a/Assets/Scripts/Games/FrogPrincess/FrogPrincess.cs b/Assets/Scripts/Games/FrogPrincess/FrogPrincess.cs index e2c27ce23..d84549312 100644 --- a/Assets/Scripts/Games/FrogPrincess/FrogPrincess.cs +++ b/Assets/Scripts/Games/FrogPrincess/FrogPrincess.cs @@ -78,105 +78,18 @@ namespace HeavenStudio.Games { if (PlayerInput.GetIsAction(InputAction_BasicPress) && !IsExpectingInputNow(InputAction_BasicPress)) { - if (!isHold && !isGone) - { - ScoreMiss(); - isGone = true; - isPrepare = false; - var currentBeat = cond.songPositionInBeatsAsDouble; - - UpdatePos(); - LotusAnims[0].DoScaledAnimationAsync("hold", 0.5f); - frogAnim.DoScaledAnimationAsync("hold", 0.5f); - SoundByte.PlayOneShotGame("frogPrincess/lean"); - SoundByte.PlayOneShotGame("frogPrincess/A"); - princessAnim.DoScaledAnimationAsync("fallForward", 0.5f); - princessAnim.DoScaledAnimationAsync("surpriseFall", 0.5f); - - BeatAction.New(instance, new List() - { - new BeatAction.Action(currentBeat + 0.75, delegate - { - LotusAnims[0].DoScaledAnimationAsync("release", 0.5f); - frogAnim.DoScaledAnimationAsync("release", 0.5f); - }), - }); - - Appear(currentBeat, false); - } + ScoreMiss(); + HoldFastAnim(cond.songPositionInBeatsAsDouble); } if (PlayerInput.GetIsAction(InputAction_FlickRelease) && !IsExpectingInputNow(InputAction_FlickRelease)) { - if (isHold && !isGone) - { - ScoreMiss(); - isHold = false; - isGone = true; - var currentBeat = cond.songPositionInBeatsAsDouble; - - UpdatePos(); - SoundByte.PlayOneShotGame("frogPrincess/jump"); - LotusAnims[0].DoScaledAnimationAsync("release", 0.5f); - StartCoroutine(MoveCo(Lotuses, currentBeat, moveTime, moveDistance)); - StartCoroutine(MoveCo(Leaves, currentBeat, moveTime, moveDistance)); - frogAnim.DoScaledAnimationAsync("jumpFast", 0.5f); - princessAnim.DoScaledAnimationAsync("jumpFast", 0.5f); - princessAnim.Play("idle", 1, 0); - - ParticleSystem spawnedParticle = Instantiate(splashEffect, transform); - BeatAction.New(instance, new List() - { - new BeatAction.Action(currentBeat + 0.5, delegate - { - SoundByte.PlayOneShotGame("frogPrincess/A"); - spawnedParticle.PlayScaledAsync(0.5f); - }), - new BeatAction.Action(currentBeat + 1, delegate - { - Destroy(spawnedParticle); - }), - }); - - Appear(currentBeat, true); - } + ScoreMiss(); + JumpFastAnim(cond.songPositionInBeatsAsDouble); } - if (PlayerInput.PlayerHasControl() && PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Touch) + if (PlayerInput.GetIsAction(InputAction_BasicRelease) && PlayerInput.PlayerHasControl() && PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Touch) { - if (PlayerInput.GetIsAction(InputAction_BasicRelease)) - { - if (isHold && !isGone) - { - ScoreMiss(); - isHold = false; - isGone = true; - var currentBeat = cond.songPositionInBeatsAsDouble; - - UpdatePos(); - SoundByte.PlayOneShotGame("frogPrincess/jump"); - LotusAnims[0].DoScaledAnimationAsync("release", 0.5f); - StartCoroutine(MoveCo(Lotuses, currentBeat, moveTime, moveDistance)); - StartCoroutine(MoveCo(Leaves, currentBeat, moveTime, moveDistance)); - frogAnim.DoScaledAnimationAsync("jumpFast", 0.5f); - princessAnim.DoScaledAnimationAsync("jumpFast", 0.5f); - princessAnim.Play("idle", 1, 0); - - ParticleSystem spawnedParticle = Instantiate(splashEffect, transform); - BeatAction.New(instance, new List() - { - new BeatAction.Action(currentBeat + 0.5, delegate - { - SoundByte.PlayOneShotGame("frogPrincess/A"); - spawnedParticle.PlayScaledAsync(0.5f); - }), - new BeatAction.Action(currentBeat + 1, delegate - { - Destroy(spawnedParticle); - }), - }); - - Appear(currentBeat, true); - } - } + ScoreMiss(); + JumpFastAnim(cond.songPositionInBeatsAsDouble); } UpdateBackgroundColor(); } @@ -189,32 +102,8 @@ namespace HeavenStudio.Games isPrepare = true; BeatAction.New(instance, new List() { - new BeatAction.Action(beat, delegate - { - if (!isGone) - { - SoundByte.PlayOneShotGame("frogPrincess/ready"); - if (!frogAnim.IsPlayingAnimationNames("jump")) - { - frogAnim.DoScaledAnimationAsync("ready", 0.5f); - princessAnim.DoScaledAnimationAsync("ready", 0.5f); - princessAnim.DoScaledAnimationAsync("wary", 0.5f); - } - } - }), - new BeatAction.Action(beat + 1, delegate - { - if (!isGone) - { - SoundByte.PlayOneShotGame("frogPrincess/ready"); - if (!frogAnim.IsPlayingAnimationNames("jump")) - { - frogAnim.DoScaledAnimationAsync("ready", 0.5f); - princessAnim.DoScaledAnimationAsync("ready", 0.5f); - princessAnim.DoScaledAnimationAsync("wary", 0.5f); - } - } - }), + new BeatAction.Action(beat, delegate { ReadyAnim();}), + new BeatAction.Action(beat + 1, delegate { ReadyAnim();}), }); ScheduleInput(beat, 2, InputAction_BasicPress, JustHold, MissHold, Empty, CanHold); @@ -223,29 +112,89 @@ namespace HeavenStudio.Games void JustHold(PlayerActionEvent caller, float state) { - isHold = true; - - UpdatePos(); - ScheduleInput(caller.timer + caller.startBeat, 1, InputAction_FlickRelease, JustJump, MissJump, Empty, CanJump); - - LotusAnims[0].DoScaledAnimationAsync("hold", 0.5f); - frogAnim.DoScaledAnimationAsync("hold", 0.5f); + var currentBeat = caller.timer + caller.startBeat; + ScheduleInput(currentBeat, 1, InputAction_FlickRelease, JustJump, MissJump, Empty, CanJump); if (state >= 1f || state <= -1f) { - SoundByte.PlayOneShotGame("frogPrincess/lean"); - SoundByte.PlayOneShotGame("frogPrincess/7"); - princessAnim.DoScaledAnimationAsync("holdBarely", 0.5f); - princessAnim.DoScaledAnimationAsync("surpriseHoldBarely", 0.5f); + HoldBarelyAnim(); return; } + HoldAnim(); + } + + void MissHold(PlayerActionEvent caller) + { + HoldMissAnim(caller.timer + caller.startBeat); + } + + bool CanHold() { return isPrepare;} + + void JustJump(PlayerActionEvent caller, float state) + { + var currentBeat = caller.timer + caller.startBeat; + + if (state >= 1f || state <= -1f) + { + JumpBarelyAnim(currentBeat); + return; + } + + JumpAnim(currentBeat); + } + + void MissJump(PlayerActionEvent caller) + { + JumpMissAnim(caller.timer + caller.startBeat); + } + + bool CanJump() { return isHold && !isGone;} + + void Empty(PlayerActionEvent caller) { } + + void ReadyAnim() + { + if (!isGone) + { + SoundByte.PlayOneShotGame("frogPrincess/ready"); + if (!frogAnim.IsPlayingAnimationNames("jump")) + { + frogAnim.DoScaledAnimationAsync("ready", 0.5f); + princessAnim.DoScaledAnimationAsync("ready", 0.5f); + princessAnim.DoScaledAnimationAsync("wary", 0.5f); + } + } + } + + void HoldAnim() + { + isHold = true; + + UpdatePos(); + LotusAnims[0].DoScaledAnimationAsync("hold", 0.5f); + frogAnim.DoScaledAnimationAsync("hold", 0.5f); + SoundByte.PlayOneShotGame("frogPrincess/lean"); princessAnim.DoScaledAnimationAsync("hold", 0.5f); princessAnim.Play("idle", 1, 0); } - void MissHold(PlayerActionEvent caller) + void HoldBarelyAnim() + { + isHold = true; + + UpdatePos(); + LotusAnims[0].DoScaledAnimationAsync("hold", 0.5f); + frogAnim.DoScaledAnimationAsync("hold", 0.5f); + + SoundByte.PlayOneShotGame("frogPrincess/lean"); + SoundByte.PlayOneShotGame("frogPrincess/7"); + princessAnim.DoScaledAnimationAsync("holdBarely", 0.5f); + princessAnim.DoScaledAnimationAsync("surpriseHoldBarely", 0.5f); + } + + void HoldMissAnim(double beat) { if (isPrepare) { @@ -257,32 +206,46 @@ namespace HeavenStudio.Games frogAnim.DoScaledAnimationAsync("fall", 0.5f); princessAnim.DoScaledAnimationAsync("fallBackward", 0.5f); - Appear(caller.timer + caller.startBeat + 0.5, false); + Appear(beat + 0.5, false); } } - bool CanHold() { return isPrepare;} + void HoldFastAnim(double beat) + { + if (!isHold && !isGone) + { + isGone = true; + isPrepare = false; - void JustJump(PlayerActionEvent caller, float state) + UpdatePos(); + LotusAnims[0].DoScaledAnimationAsync("hold", 0.5f); + frogAnim.DoScaledAnimationAsync("hold", 0.5f); + SoundByte.PlayOneShotGame("frogPrincess/lean"); + SoundByte.PlayOneShotGame("frogPrincess/A"); + princessAnim.DoScaledAnimationAsync("fallForward", 0.5f); + princessAnim.DoScaledAnimationAsync("surpriseFall", 0.5f); + + BeatAction.New(instance, new List() + { + new BeatAction.Action(beat + 0.75, delegate + { + LotusAnims[0].DoScaledAnimationAsync("release", 0.5f); + frogAnim.DoScaledAnimationAsync("release", 0.5f); + }), + }); + + Appear(beat, false); + } + } + + void JumpAnim(double beat) { isHold = false; - var currentBeat = caller.timer + caller.startBeat; UpdatePos(); LotusAnims[0].DoScaledAnimationAsync("release", 0.5f); - StartCoroutine(MoveCo(Lotuses, currentBeat, moveTime, moveDistance)); - StartCoroutine(MoveCo(Leaves, currentBeat, moveTime, moveDistance)); - - if (state >= 1f || state <= -1f) - { - SoundByte.PlayOneShotGame("frogPrincess/jump"); - SoundByte.PlayOneShotGame("frogPrincess/7", currentBeat + 0.5); - LotusAnims[1].DoScaledAnimationAsync("jumpBarely", 0.5f); - frogAnim.DoScaledAnimationAsync("jumpBarely", 0.5f); - princessAnim.DoScaledAnimationAsync("jumpBarely", 0.5f); - princessAnim.DoScaledAnimationAsync("surpriseJumpBarely", 0.5f); - return; - } + StartCoroutine(MoveCo(Lotuses, beat, moveTime, moveDistance)); + StartCoroutine(MoveCo(Leaves, beat, moveTime, moveDistance)); SoundByte.PlayOneShotGame("frogPrincess/jump"); LotusAnims[1].DoScaledAnimationAsync("jump", 0.5f); @@ -291,13 +254,29 @@ namespace HeavenStudio.Games princessAnim.DoScaledAnimationAsync("happy", 0.5f); } - void MissJump(PlayerActionEvent caller) + void JumpBarelyAnim(double beat) + { + isHold = false; + + UpdatePos(); + LotusAnims[0].DoScaledAnimationAsync("release", 0.5f); + StartCoroutine(MoveCo(Lotuses, beat, moveTime, moveDistance)); + StartCoroutine(MoveCo(Leaves, beat, moveTime, moveDistance)); + + SoundByte.PlayOneShotGame("frogPrincess/jump"); + SoundByte.PlayOneShotGame("frogPrincess/7", beat + 0.5); + LotusAnims[1].DoScaledAnimationAsync("jumpBarely", 0.5f); + frogAnim.DoScaledAnimationAsync("jumpBarely", 0.5f); + princessAnim.DoScaledAnimationAsync("jumpBarely", 0.5f); + princessAnim.DoScaledAnimationAsync("surpriseJumpBarely", 0.5f); + } + + void JumpMissAnim(double beat) { if (isHold && !isGone) { isHold = false; isGone = true; - var currentBeat = caller.timer + caller.startBeat; UpdatePos(); SoundByte.PlayOneShotGame("frogPrincess/A"); @@ -305,13 +284,43 @@ namespace HeavenStudio.Games frogAnim.DoScaledAnimationAsync("fall", 0.5f); princessAnim.DoScaledAnimationAsync("fallForward", 0.5f); - Appear(currentBeat, false); + Appear(beat, false); } } - bool CanJump() { return isHold && !isGone;} + void JumpFastAnim(double beat) + { + if (isHold && !isGone) + { + isHold = false; + isGone = true; - void Empty(PlayerActionEvent caller) { } + UpdatePos(); + SoundByte.PlayOneShotGame("frogPrincess/jump"); + LotusAnims[0].DoScaledAnimationAsync("release", 0.5f); + StartCoroutine(MoveCo(Lotuses, beat, moveTime, moveDistance)); + StartCoroutine(MoveCo(Leaves, beat, moveTime, moveDistance)); + frogAnim.DoScaledAnimationAsync("jumpFast", 0.5f); + princessAnim.DoScaledAnimationAsync("jumpFast", 0.5f); + princessAnim.Play("idle", 1, 0); + + ParticleSystem spawnedParticle = Instantiate(splashEffect, transform); + BeatAction.New(instance, new List() + { + new BeatAction.Action(beat + 0.5, delegate + { + SoundByte.PlayOneShotGame("frogPrincess/A"); + spawnedParticle.PlayScaledAsync(0.5f); + }), + new BeatAction.Action(beat + 1, delegate + { + Destroy(spawnedParticle); + }), + }); + + Appear(beat, true); + } + } public float moveDistance; public float moveTime;