Merge branch 'agents/wall-jump-logic-optimization'

# Conflicts:
#	Assets/_Game/Scripts/Player/PlayerMovement.cs
#	Assets/_Game/Scripts/Player/States/IdleState.cs
#	Assets/_Game/Scripts/Player/States/RunState.cs
#	Assets/_Game/Scripts/Player/States/WallJumpState.cs
#	Assets/_Game/Scripts/Player/States/WallSlideState.cs
This commit is contained in:
2026-05-19 13:03:04 +08:00
7 changed files with 95 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ namespace BaseGames.Player.States
///
/// 公共规则:
/// 视为第一段跳(不消耗空中跳跃次数);支持可变高度(提前松键截断);
/// 蹬墙后标记 PostWallJump允许空中靠近墙壁时自动抓墙
/// 上升结束后转 FallState。
/// </summary>
public class WallJumpState : PlayerStateBase
@@ -48,12 +49,17 @@ namespace BaseGames.Player.States
_inputLockTimer = Cfg.WallJumpInputLockDuration;
// 标记蹬墙跳后自动抓墙(在 FallState/JumpState 中消耗)
Owner.SetPostWallJump(true);
// 蹬墙成功后立即恢复空中冲刺次数
Owner.GetState<AerialDashState>()?.ResetAerialDashes();
// 播放蹬墙跳动画:背墙跳/对墙跳使用各自专属 Clip留空时回退到 Jump 动画
var wallJumpClip = _isAwayJump
? (AnimCfg?.WallJumpAway ?? AnimCfg?.Jump)
: (AnimCfg?.WallJumpToward ?? AnimCfg?.Jump);
if (wallJumpClip != null) Anim?.Play(wallJumpClip);
Input.JumpCancelledEvent += OnJumpCancelled;
}
@@ -64,7 +70,18 @@ namespace BaseGames.Player.States
public override void OnStateUpdate()
{
// 上升结束 → 下落
// 输入锁结束后检查是否贴墙:自动抓墙(优先于下落判断)
if (_inputLockTimer <= 0f)
{
var wd = Owner.WallDetector;
if (wd != null && wd.IsTouchingWall && !Move.IsGrounded)
{
Owner.TransitionTo(Owner.GetState<WallSlideState>());
return;
}
}
// 上升结束 → 下落isPostWallJump 标记保留FallState 中继续支持自动抓墙)
if (!Move.IsRising)
{
Owner.TransitionTo(Owner.GetState<FallState>());