摄像机区域的架构改动
This commit is contained in:
46
Assets/_Game/Scripts/Player/States/IdleState.cs
Normal file
46
Assets/_Game/Scripts/Player/States/IdleState.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BaseGames.Player.States
|
||||
{
|
||||
/// <summary>闲置状态。默认入口状态,播放 Idle 动画。</summary>
|
||||
public class IdleState : PlayerStateBase
|
||||
{
|
||||
public IdleState(PlayerController owner) : base(owner) { }
|
||||
|
||||
public override void OnStateEnter()
|
||||
{
|
||||
if (AnimCfg?.Idle != null)
|
||||
Anim.Play(AnimCfg.Idle);
|
||||
Move?.ZeroHorizontalVelocity();
|
||||
// 落地时重置空中能力计数器
|
||||
Owner.GetState<AerialDashState>()?.ResetAerialDashes();
|
||||
Owner.ResetAirJumps();
|
||||
}
|
||||
|
||||
public override void OnStateUpdate()
|
||||
{
|
||||
if (!Move.IsGrounded)
|
||||
{
|
||||
_owner.TransitionTo(_owner.GetState<FallState>());
|
||||
return;
|
||||
}
|
||||
if (Buffer.ConsumeJump())
|
||||
{
|
||||
_owner.TransitionTo(_owner.GetState<JumpState>());
|
||||
return;
|
||||
}
|
||||
// 地面冲刺:需解锁 Dash 能力,且冲刺不在冷却
|
||||
if (Buffer.ConsumeDash()
|
||||
&& Stats != null && Stats.HasAbility(AbilityType.Dash)
|
||||
&& Owner.GetState<DashState>() is { CanDash: true } dashState)
|
||||
{
|
||||
_owner.TransitionTo(dashState);
|
||||
return;
|
||||
}
|
||||
if (Mathf.Abs(Input.MoveInput.x) > 0.1f)
|
||||
{
|
||||
_owner.TransitionTo(_owner.GetState<RunState>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user