From 08f7532145e52f1d514ade24dfe5acd902b3ee1b Mon Sep 17 00:00:00 2001 From: kimura Date: Thu, 21 Jul 2022 17:45:08 +0900 Subject: [PATCH] =?UTF-8?q?=E8=90=BD=E4=B8=8B=E3=82=A2=E3=82=AF=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/MiniGame/Scripts/Player.cs | 58 ++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs index 48e6cf5a..ff4f73bd 100644 --- a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs +++ b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs @@ -86,7 +86,7 @@ namespace MyGame.Scenes.MiniGame.Scripts public void Move() { - if (isHitStay.Value) + if (isHitStay.Value || isWall) { return; } @@ -100,7 +100,7 @@ namespace MyGame.Scenes.MiniGame.Scripts public void Jump() { - if (isJump || isHit) + if (isJump || isHit || isHole) { return; } @@ -149,7 +149,7 @@ namespace MyGame.Scenes.MiniGame.Scripts if (isFall && active && !isFlying) { isFlying = true; - var currentSpeed = 0f; + currentFallSpeed = 0f; this.SafeStopCoroutine(jumpFallCoroutine); jumpHoldDisposable?.Dispose(); jumpHoldDisposable = this.UpdateAsObservable() @@ -159,16 +159,17 @@ namespace MyGame.Scenes.MiniGame.Scripts // 滑空or落下切り替え if (isButtonHold) { - currentSpeed = -flyingFallSpeed; + currentFallSpeed = -flyingFallSpeed; } else { - currentSpeed -= fallAcceleration * Time.deltaTime; + currentFallSpeed -= fallAcceleration * Time.deltaTime; } - transform.AddLocalPositionY(currentSpeed * Time.deltaTime); + transform.AddLocalPositionY(currentFallSpeed * Time.deltaTime); }, () => { + currentFallSpeed = 0f; isJump = false; isFall = false; isFlying = false; @@ -189,7 +190,7 @@ namespace MyGame.Scenes.MiniGame.Scripts } Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent); - animator?.Play("Brother_pink_FallDown"); + animator?.Play("Brother_pink_FallDown", 0, 0f); isHit = true; hitCompositeDisposable?.Clear(); @@ -200,26 +201,28 @@ namespace MyGame.Scenes.MiniGame.Scripts var cachePosY = transform.localPosition.y; var diffHeight = cachePosY - basePos.y; - jumpCoroutine = this.CallLerp(diffHeight == 0f ? 0f : hitJumpTime, t => + var groundPos = isHole ? cachePosY : basePos.y; + jumpCoroutine = this.CallLerp(diffHeight <= 0f ? 0f : hitJumpTime, t => { transform.SetLocalPositionY(cachePosY + hitAnimationCurve.Evaluate(t)); }, () => { // 落下時間不定によりアニメ再生停止 animator.speed = 0f; - var currentSpeed = 0f; + currentFallSpeed = 0f; this.UpdateAsObservable() - .TakeWhile(_ => transform.localPosition.y > basePos.y) + .TakeWhile(_ => transform.localPosition.y > groundPos) .Subscribe(_ => { - currentSpeed -= fallAcceleration * Time.deltaTime; - transform.AddLocalPositionY(currentSpeed * Time.deltaTime); + currentFallSpeed -= fallAcceleration * Time.deltaTime; + transform.AddLocalPositionY(currentFallSpeed * Time.deltaTime); }, () => { // 31フレームまでが落下32からズサー animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .5f); animator.speed = 1f; - transform.SetLocalPositionY(basePos.y); + transform.SetLocalPositionY(groundPos); + currentFallSpeed = 0f; isJump = false; isFall = false; isFlying = false; @@ -244,6 +247,35 @@ namespace MyGame.Scenes.MiniGame.Scripts }); } + public void Hole() + { + // 落下開始 + isHole = true; + + // animator?.Play("Brother_pink_main_stay"); + isJump = false; + isFall = false; + isFlying = false; + isHit = false; + isHitStay.Value = false; + hitCompositeDisposable?.Clear(); + jumpHoldDisposable?.Dispose(); + jumpHoldDisposable = this.UpdateAsObservable() + // .TakeWhile(_ => transform.localPosition.y > basePos.y) + .Subscribe(_ => + { + currentFallSpeed -= fallAcceleration * Time.deltaTime; + transform.AddLocalPositionY(currentFallSpeed * Time.deltaTime); + }, () => + { + }).AddTo(this); + } + + public void Wall() + { + isWall = true; + } + public void Result() { if (isJump || isHit)