- PlayerController: 添加 wallGrabY/wallGrabDir/isPostWallJump 字段及 API - WallSlideState: 高度限制(超限强制下滑不可蹬跳)+ 静止悬挂 + 反向键释放 - WallJumpState: 区分背墙跳(WallJumpAwayForce)/对墙跳(WallJumpBackForce) 蹬墙后标记 PostWallJump 允许空中自动抓墙;恢复空中冲刺次数 - FallState/JumpState: 新增抓墙入口(朝向按键 OR PostWallJump 自动抓墙) - PlayerMovement.WallJump: 增加 jumpAway 参数区分两种跳跃力 - IdleState/RunState: 落地时重置抓墙记录和蹬墙跳标记 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
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();
|
|
Owner.ResetWallGrab();
|
|
Owner.SetPostWallJump(false);
|
|
}
|
|
|
|
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>());
|
|
}
|
|
}
|
|
}
|
|
}
|