feat: 实现抓墙高度记忆、背墙跳/对墙跳、蹬墙后自动抓墙

- 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>
This commit is contained in:
2026-05-19 12:12:24 +08:00
parent d25f237e76
commit 2a6a0b1861
8 changed files with 172 additions and 22 deletions

View File

@@ -180,13 +180,26 @@ namespace BaseGames.Player
}
/// <summary>
/// 蹬墙跳:对墙方向施加相反水平力 + 向上力
/// wallDir = +1 (右墙) 或 -1 (左墙),跳跃方向与之相反
/// 蹬墙跳:根据跳跃类型施加不同速度
/// wallDir = +1 (右墙) 或 -1 (左墙)。
/// jumpAway = true背墙跳朝远离墙壁方向施加 WallJumpAwayForceX/Y
/// jumpAway = false对墙跳朝墙壁方向施加 WallJumpBackForceX + WallJumpForceY。
/// </summary>
public void WallJump(int wallDir)
public void WallJump(int wallDir, bool jumpAway)
{
float forceX = -wallDir * _config.WallJumpForceX;
float forceY = _config.WallJumpForceY;
float forceX, forceY;
if (jumpAway)
{
// 背墙跳:远离墙壁方向弹出
forceX = -wallDir * _config.WallJumpAwayForceX;
forceY = _config.WallJumpAwayForceY;
}
else
{
// 对墙跳:偏向垂直向上,水平分量朝向墙壁
forceX = wallDir * _config.WallJumpBackForceX;
forceY = _config.WallJumpForceY;
}
_rb.velocity = new Vector2(forceX, forceY);
_coyoteTimer = 0f;
}