落下アクション対応
This commit is contained in:
parent
e7960e1c1e
commit
08f7532145
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue