落下アクション対応
This commit is contained in:
parent
e7960e1c1e
commit
08f7532145
|
|
@ -86,7 +86,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
|
|
||||||
public void Move()
|
public void Move()
|
||||||
{
|
{
|
||||||
if (isHitStay.Value)
|
if (isHitStay.Value || isWall)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +100,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
|
|
||||||
public void Jump()
|
public void Jump()
|
||||||
{
|
{
|
||||||
if (isJump || isHit)
|
if (isJump || isHit || isHole)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +149,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
if (isFall && active && !isFlying)
|
if (isFall && active && !isFlying)
|
||||||
{
|
{
|
||||||
isFlying = true;
|
isFlying = true;
|
||||||
var currentSpeed = 0f;
|
currentFallSpeed = 0f;
|
||||||
this.SafeStopCoroutine(jumpFallCoroutine);
|
this.SafeStopCoroutine(jumpFallCoroutine);
|
||||||
jumpHoldDisposable?.Dispose();
|
jumpHoldDisposable?.Dispose();
|
||||||
jumpHoldDisposable = this.UpdateAsObservable()
|
jumpHoldDisposable = this.UpdateAsObservable()
|
||||||
|
|
@ -159,16 +159,17 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
// 滑空or落下切り替え
|
// 滑空or落下切り替え
|
||||||
if (isButtonHold)
|
if (isButtonHold)
|
||||||
{
|
{
|
||||||
currentSpeed = -flyingFallSpeed;
|
currentFallSpeed = -flyingFallSpeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentSpeed -= fallAcceleration * Time.deltaTime;
|
currentFallSpeed -= fallAcceleration * Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.AddLocalPositionY(currentSpeed * Time.deltaTime);
|
transform.AddLocalPositionY(currentFallSpeed * Time.deltaTime);
|
||||||
}, () =>
|
}, () =>
|
||||||
{
|
{
|
||||||
|
currentFallSpeed = 0f;
|
||||||
isJump = false;
|
isJump = false;
|
||||||
isFall = false;
|
isFall = false;
|
||||||
isFlying = false;
|
isFlying = false;
|
||||||
|
|
@ -189,7 +190,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
}
|
}
|
||||||
|
|
||||||
Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent);
|
Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent);
|
||||||
animator?.Play("Brother_pink_FallDown");
|
animator?.Play("Brother_pink_FallDown", 0, 0f);
|
||||||
isHit = true;
|
isHit = true;
|
||||||
hitCompositeDisposable?.Clear();
|
hitCompositeDisposable?.Clear();
|
||||||
|
|
||||||
|
|
@ -200,26 +201,28 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
|
|
||||||
var cachePosY = transform.localPosition.y;
|
var cachePosY = transform.localPosition.y;
|
||||||
var diffHeight = cachePosY - basePos.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));
|
transform.SetLocalPositionY(cachePosY + hitAnimationCurve.Evaluate(t));
|
||||||
}, () =>
|
}, () =>
|
||||||
{
|
{
|
||||||
// 落下時間不定によりアニメ再生停止
|
// 落下時間不定によりアニメ再生停止
|
||||||
animator.speed = 0f;
|
animator.speed = 0f;
|
||||||
var currentSpeed = 0f;
|
currentFallSpeed = 0f;
|
||||||
this.UpdateAsObservable()
|
this.UpdateAsObservable()
|
||||||
.TakeWhile(_ => transform.localPosition.y > basePos.y)
|
.TakeWhile(_ => transform.localPosition.y > groundPos)
|
||||||
.Subscribe(_ =>
|
.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
currentSpeed -= fallAcceleration * Time.deltaTime;
|
currentFallSpeed -= fallAcceleration * Time.deltaTime;
|
||||||
transform.AddLocalPositionY(currentSpeed * Time.deltaTime);
|
transform.AddLocalPositionY(currentFallSpeed * Time.deltaTime);
|
||||||
}, () =>
|
}, () =>
|
||||||
{
|
{
|
||||||
// 31フレームまでが落下32からズサー
|
// 31フレームまでが落下32からズサー
|
||||||
animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .5f);
|
animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .5f);
|
||||||
animator.speed = 1f;
|
animator.speed = 1f;
|
||||||
transform.SetLocalPositionY(basePos.y);
|
transform.SetLocalPositionY(groundPos);
|
||||||
|
currentFallSpeed = 0f;
|
||||||
isJump = false;
|
isJump = false;
|
||||||
isFall = false;
|
isFall = false;
|
||||||
isFlying = 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()
|
public void Result()
|
||||||
{
|
{
|
||||||
if (isJump || isHit)
|
if (isJump || isHit)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue