不要な跳ね返りアニメーションを無効化

This commit is contained in:
kimura 2022-07-26 15:59:20 +09:00
parent 1e81efb434
commit 409cf9134d
1 changed files with 54 additions and 41 deletions

View File

@ -198,41 +198,55 @@ 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(_ =>
{
HitFallDown(groundPos);
}).AddTo(hitCompositeDisposable);
}
private void HitFallDown(float groundPos)
{
// 落下時間不定によりアニメ再生停止
animator.speed = 0f;
@ -241,7 +255,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
{
// 31フレームまでが落下32からズサー
SoundManager.Instance.PlaySE("se_minigame_FallDown");
animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .5f);
animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .52f);
animator.speed = currentSpeedMultiply;
currentFallSpeed = 0f;
isJump = false;
@ -265,7 +279,6 @@ namespace MyGame.Scenes.MiniGame.Scripts
}).AddTo(hitCompositeDisposable);
}).AddTo(hitCompositeDisposable);
}).AddTo(hitCompositeDisposable);
}).AddTo(hitCompositeDisposable);
}
public void Hole()