角色能力,存档
This commit is contained in:
@@ -66,6 +66,13 @@ namespace BaseGames.Player.States
|
||||
#if UNITY_EDITOR
|
||||
[Header("调试")]
|
||||
[SerializeField] private bool _debugValidateTransitions = true;
|
||||
|
||||
[Header("── 运行时状态 ──")]
|
||||
[SerializeField] private string _dbg_CurrentState;
|
||||
[SerializeField] private bool _dbg_IsGrounded;
|
||||
[SerializeField] private int _dbg_AirJumpsLeft;
|
||||
[SerializeField] private bool _dbg_CanDash;
|
||||
[SerializeField] private bool _dbg_IsInvincible;
|
||||
#endif
|
||||
|
||||
// Overlay Layer(Layer 1):供 SpringState / SoulSkill 等叠加层动画使用
|
||||
@@ -139,10 +146,12 @@ namespace BaseGames.Player.States
|
||||
public void UseAirJump() => _airJumpsLeft = Mathf.Max(0, _airJumpsLeft - 1);
|
||||
/// <summary>
|
||||
/// 落地时重置空中跳跃次数(由 IdleState/RunState.OnStateEnter 调用)。
|
||||
/// 若解锁 DoubleJump 则重置为 1,否则为 0。
|
||||
/// 若解锁 DoubleJump 则重置为 MovConfig.MaxAirJumps,否则为 0。
|
||||
/// </summary>
|
||||
public void ResetAirJumps() =>
|
||||
_airJumpsLeft = _stats != null && _stats.HasAbility(AbilityType.DoubleJump) ? 1 : 0;
|
||||
_airJumpsLeft = (_stats != null && _stats.HasAbility(AbilityType.DoubleJump))
|
||||
? (_movementConfig != null ? _movementConfig.MaxAirJumps : 1)
|
||||
: 0;
|
||||
|
||||
// ── Overlay Layer API(供 SpringState / SoulSkill 等叠加动画使用)─────
|
||||
/// <summary>
|
||||
@@ -192,6 +201,10 @@ namespace BaseGames.Player.States
|
||||
_parrySystem.OnParryActivated += OnParryActivated;
|
||||
_parrySystem.OnParryConsumed += OnParryConsumedHandler;
|
||||
}
|
||||
|
||||
// 订阅灵泉使用输入
|
||||
if (_inputReader != null)
|
||||
_inputReader.UseSpringEvent += OnUseSpring;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
@@ -201,6 +214,9 @@ namespace BaseGames.Player.States
|
||||
_parrySystem.OnParryActivated -= OnParryActivated;
|
||||
_parrySystem.OnParryConsumed -= OnParryConsumedHandler;
|
||||
}
|
||||
|
||||
if (_inputReader != null)
|
||||
_inputReader.UseSpringEvent -= OnUseSpring;
|
||||
}
|
||||
|
||||
/// <summary>弹反输入激活时由 ParrySystem 触发 → 转换到 ParryState。</summary>
|
||||
@@ -217,6 +233,15 @@ namespace BaseGames.Player.States
|
||||
_shield?.OnParrySuccess();
|
||||
}
|
||||
|
||||
/// <summary>灵泉输入:地面且有剩余充能时转入 SpringState 使用一次。</summary>
|
||||
private void OnUseSpring()
|
||||
{
|
||||
if (_stats == null || _stats.CurrentSpringCharges <= 0) return;
|
||||
if (_movement != null && !_movement.IsGrounded) return;
|
||||
if (_states.ContainsKey(typeof(SpringState)))
|
||||
TransitionTo(GetState<SpringState>());
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (!HasRequiredStateDependencies())
|
||||
@@ -238,6 +263,14 @@ namespace BaseGames.Player.States
|
||||
GetState<DashState>()?.TickCooldown(Time.deltaTime);
|
||||
|
||||
_currentState?.OnStateUpdate();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
_dbg_CurrentState = _currentState?.GetType().Name ?? "None";
|
||||
_dbg_IsGrounded = _movement != null && _movement.IsGrounded;
|
||||
_dbg_AirJumpsLeft = _airJumpsLeft;
|
||||
_dbg_CanDash = GetState<DashState>()?.CanDash ?? false;
|
||||
_dbg_IsInvincible = _stats != null && _stats.IsInvincible;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
@@ -276,7 +309,6 @@ namespace BaseGames.Player.States
|
||||
_states[typeof(FallState)] = new FallState(this);
|
||||
_states[typeof(AttackState)] = new AttackState(this);
|
||||
_states[typeof(DashState)] = new DashState(this);
|
||||
_states[typeof(AerialDashState)] = new AerialDashState(this);
|
||||
_states[typeof(WallSlideState)] = new WallSlideState(this);
|
||||
_states[typeof(WallJumpState)] = new WallJumpState(this);
|
||||
_states[typeof(AirAttackState)] = new AirAttackState(this);
|
||||
|
||||
Reference in New Issue
Block a user