From bfda4665835b4460beaa6e3b7c9bcc5879a1a436 Mon Sep 17 00:00:00 2001 From: kimura Date: Thu, 21 Jul 2022 14:51:21 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=92=E3=83=83=E3=83=88=E5=8B=95=E4=BD=9C?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/MiniGame/MiniGame.unity | 119 ++++++++++++------ .../MyGame/Scenes/MiniGame/Scripts/Player.cs | 67 ++++++---- 2 files changed, 120 insertions(+), 66 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/MiniGame/MiniGame.unity b/popcorn/Assets/MyGame/Scenes/MiniGame/MiniGame.unity index 157608b4..54630895 100644 --- a/popcorn/Assets/MyGame/Scenes/MiniGame/MiniGame.unity +++ b/popcorn/Assets/MyGame/Scenes/MiniGame/MiniGame.unity @@ -417,7 +417,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: bedef2aeaac8da04faa9a07b7241d0ad, type: 3} m_Name: m_EditorClassIdentifier: - mTarget: {fileID: 4559813503860727176} + mTarget: {fileID: 0} --- !u!224 &475061233 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 7328251774731631637, guid: b46e011db918bbe42a91795497f90b9c, @@ -1392,16 +1392,91 @@ PrefabInstance: propertyPath: fallSpeed value: 0.07 objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitJumpTime + value: 0.3 + objectReference: {fileID: 0} - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, type: 3} propertyPath: fallAcceleration value: 30 objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_PostInfinity + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.size + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[0].time + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[1].time + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[0].value + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[1].value + value: 1 + objectReference: {fileID: 0} - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, type: 3} propertyPath: jumpAnimationCurve.m_Curve.Array.data[1].value value: 6.5 objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[0].inSlope + value: 2.4237015 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[1].inSlope + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[0].outSlope + value: 2.4237015 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[1].inWeight + value: 0.33333334 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[1].outSlope + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[0].outWeight + value: 0.04351728 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[0].tangentMode + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2607884839347368726, guid: acd6e6365b5fe4863aedc684a50b8028, + type: 3} + propertyPath: hitAnimationCurve.m_Curve.Array.data[1].tangentMode + value: 0 + objectReference: {fileID: 0} - target: {fileID: 4931350312200274921, guid: acd6e6365b5fe4863aedc684a50b8028, type: 3} propertyPath: m_RootOrder @@ -1826,7 +1901,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: bedef2aeaac8da04faa9a07b7241d0ad, type: 3} m_Name: m_EditorClassIdentifier: - mTarget: {fileID: 4559813503860727175} + mTarget: {fileID: 0} --- !u!1 &1450368325 GameObject: m_ObjectHideFlags: 0 @@ -2176,7 +2251,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: bedef2aeaac8da04faa9a07b7241d0ad, type: 3} m_Name: m_EditorClassIdentifier: - mTarget: {fileID: 4559813503860727174} + mTarget: {fileID: 0} --- !u!1001 &1862591111 PrefabInstance: m_ObjectHideFlags: 0 @@ -2723,7 +2798,7 @@ PrefabInstance: - target: {fileID: 2233378810729895866, guid: 4700f2d6cab15484295a1f9b42d78ec9, type: 3} propertyPath: m_RootOrder - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 2233378810729895866, guid: 4700f2d6cab15484295a1f9b42d78ec9, type: 3} @@ -3111,42 +3186,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &4559813503860727174 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 4559813505704525543, guid: 041c0f3d96c90d64094cc76c5c87c26f, - type: 3} - m_PrefabInstance: {fileID: 4559813503860727169} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!114 &4559813503860727175 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 4559813504388152431, guid: 041c0f3d96c90d64094cc76c5c87c26f, - type: 3} - m_PrefabInstance: {fileID: 4559813503860727169} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!114 &4559813503860727176 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 4559813505652122421, guid: 041c0f3d96c90d64094cc76c5c87c26f, - type: 3} - m_PrefabInstance: {fileID: 4559813503860727169} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1001 &5034752974072861411 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs index 92c9fb0a..881bdadc 100644 --- a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs +++ b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs @@ -8,7 +8,7 @@ namespace MyGame.Scenes.MiniGame.Scripts public class Player : MonoBehaviour { [SerializeField] private float speed = 5f; - [SerializeField] private float fallTime = 1f; + [SerializeField] private float hitJumpTime = 1f; [SerializeField] private float hitTime = 1.5f; [SerializeField] private float hitWaitTime = 1f; [SerializeField] private AnimationCurve jumpAnimationCurve; @@ -164,43 +164,58 @@ namespace MyGame.Scenes.MiniGame.Scripts } Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent); - SoundManager.Instance.PlaySE("se_minigame_Collide"); animator?.Play("Brother_pink_FallDown"); isHit = true; hitDisposable?.Dispose(); + // ヒット以外動作停止 this.SafeStopCoroutine(jumpCoroutine); this.SafeStopCoroutine(jumpFallCoroutine); jumpHoldDisposable?.Dispose(); - var diffHeight = transform.localPosition.y - basePos.y; - jumpCoroutine = this.CallLerp(diffHeight == 0f ? 0f : fallTime, t => + + var cachePosY = transform.localPosition.y; + var diffHeight = cachePosY - basePos.y; + jumpCoroutine = this.CallLerp(diffHeight == 0f ? 0f : hitJumpTime, t => { - transform.SetLocalPositionY(basePos.y + hitAnimationCurve.Evaluate(t) * diffHeight); + transform.SetLocalPositionY(cachePosY + hitAnimationCurve.Evaluate(t)); }, () => { - isJump = false; - isFall = false; - isFlying = false; - SoundManager.Instance.PlaySE("se_minigame_FallDown"); - this.CallLerp(hitTime, t => - { - }, () => - { - isHitStay.Value = true; - this.CallWaitForSeconds(hitWaitTime, () => + // 落下時間不定によりアニメ再生停止 + animator.speed = 0f; + var currentSpeed = 0f; + this.UpdateAsObservable() + .TakeWhile(_ => transform.localPosition.y > basePos.y) + .Subscribe(_ => { - isHit = false; - isHitStay.Value = false; - if (isResult) + currentSpeed -= fallAcceleration * Time.deltaTime; + transform.AddLocalPositionY(currentSpeed * Time.deltaTime); + }, () => + { + // 31フレームまでが落下32からズサー + animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .5f); + animator.speed = 1f; + transform.SetLocalPositionY(basePos.y); + isJump = false; + isFall = false; + isFlying = false; + this.CallWaitForSeconds(hitTime, () => { - Result(); - } - else - { - Stay(); - } - }); - }); + isHitStay.Value = true; + this.CallWaitForSeconds(hitWaitTime, () => + { + isHit = false; + isHitStay.Value = false; + if (isResult) + { + Result(); + } + else + { + Stay(); + } + }); + }); + }).AddTo(this); }); }