From 409cf9134db506b793526681e5413de98bbcab3f Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 26 Jul 2022 15:59:20 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E8=B7=B3=E3=81=AD?= =?UTF-8?q?=E8=BF=94=E3=82=8A=E3=82=A2=E3=83=8B=E3=83=A1=E3=83=BC=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=82=92=E7=84=A1=E5=8A=B9=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/MiniGame/Scripts/Player.cs | 95 +++++++++++-------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs index fd4f4164..fdcca4d2 100644 --- a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs +++ b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs @@ -197,72 +197,85 @@ namespace MyGame.Scenes.MiniGame.Scripts { return; } - + + jumpCompositeDisposable.Clear(); + hitCompositeDisposable.Clear(); + var cachePosY = transform.localPosition.y; + var groundPos = isHole ? cachePosY : basePos.y; + var diffHeight = cachePosY - basePos.y; + + // Hitアニメーション中に穴に落ちた場合ズサーのみ if (isHit && isHole) { endHitSubject.OnNext(Unit.Default); - } - else - { - Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent); - SoundManager.Instance.PlaySE("se_minigame_Collide"); + HitFallDown(groundPos); + return; } isHit = true; isHitStop = true; - hitCompositeDisposable.Clear(); - jumpCompositeDisposable.Clear(); - + Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent); + SoundManager.Instance.PlaySE("se_minigame_Collide"); animator?.Play("Brother_pink_FallDown", 0, 0f); animator.speed = 0f; - var hitStopTimer = Observable.Timer(TimeSpan.FromSeconds(isHit && isHole ? 0f : hitStopTime)).Share(); + var hitStopTimer = Observable.Timer(TimeSpan.FromSeconds(hitStopTime)).Share(); hitStopTimer.Subscribe(_ => { isHitStop = false; animator.speed = currentSpeedMultiply; }).AddTo(hitCompositeDisposable); - - var cachePosY = transform.localPosition.y; - var diffHeight = cachePosY - basePos.y; - var groundPos = isHole ? cachePosY : basePos.y; + + // HitStop後、Hit跳ね返りアニメーション + if (isHole) + { + hitStopTimer.Subscribe(_ => + { + HitFallDown(groundPos); + }).AddTo(hitCompositeDisposable); + return; + } + var hitJumpCoroutine = MonoBehaviourExtensions.DoCallLerp(diffHeight <= 0f ? 0f : hitJumpTime / currentSpeedMultiply, t => { transform.SetLocalPositionY(cachePosY + hitAnimationCurve.Evaluate(t)); }); - - // HitStop後、Hit跳ね返りアニメーション hitStopTimer.SelectMany(hitJumpCoroutine).Subscribe(_ => { - // 落下時間不定によりアニメ再生停止 - animator.speed = 0f; + HitFallDown(groundPos); + }).AddTo(hitCompositeDisposable); + } + + private void HitFallDown(float groundPos) + { + // 落下時間不定によりアニメ再生停止 + animator.speed = 0f; + currentFallSpeed = 0f; + FallDown(groundPos, () => + { + // 31フレームまでが落下32からズサー + SoundManager.Instance.PlaySE("se_minigame_FallDown"); + animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .52f); + animator.speed = currentSpeedMultiply; currentFallSpeed = 0f; - FallDown(groundPos, () => + isJump = false; + isFall = false; + Observable.Timer(TimeSpan.FromSeconds(hitTime / currentSpeedMultiply)).Subscribe(_ => { }, () => { - // 31フレームまでが落下32からズサー - SoundManager.Instance.PlaySE("se_minigame_FallDown"); - animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .5f); - animator.speed = currentSpeedMultiply; - currentFallSpeed = 0f; - isJump = false; - isFall = false; - Observable.Timer(TimeSpan.FromSeconds(hitTime / currentSpeedMultiply)).Subscribe(_ => { }, () => + isHitStay = true; + Observable.Timer(TimeSpan.FromSeconds(hitWaitTime)).Subscribe(_ => { }, () => { - isHitStay = true; - Observable.Timer(TimeSpan.FromSeconds(hitWaitTime)).Subscribe(_ => { }, () => + endHitSubject.OnNext(Unit.Default); + isHit = false; + isHitStay = false; + if (isResult) { - endHitSubject.OnNext(Unit.Default); - isHit = false; - isHitStay = false; - if (isResult) - { - Result(); - } - else - { - Stay(); - } - }).AddTo(hitCompositeDisposable); + Result(); + } + else + { + Stay(); + } }).AddTo(hitCompositeDisposable); }).AddTo(hitCompositeDisposable); }).AddTo(hitCompositeDisposable);