- Added DownDash ability with cooldown and speed configuration. - Introduced DownDashState to handle down dashing mechanics, including gravity manipulation and animation playback. - Updated PlayerMovement to support DownDash functionality. - Enhanced PlayerStats to manage spring charge consumption and healing. - Modified PlayerCombat and WeaponHitBoxInstance to support new hit confirmation events. - Updated AbilityType to include new form types for character abilities. - Improved Gizmos for better visualization of enemy detection and attack ranges. - Added feedback systems for form switching in PlayerFeedback and IFeedbackPlayer. - Refactored combat and movement states to accommodate new abilities and ensure smooth transitions.
58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
namespace BaseGames.Player.States
|
||
{
|
||
/// <summary>
|
||
/// 使用灵泉(治疗)状态(架构 05_PlayerModule §2)。
|
||
/// 消耗 SpringCharge,播放治愈动画;动画结束后回到 Idle。
|
||
/// 需在地面且有充能才能进入(PlayerController 负责条件检查)。
|
||
///
|
||
/// 动画在 Overlay Layer(Layer 1)播放,叠加于 Base Layer 的 Idle/Run 之上,
|
||
/// 符合架构 05_PlayerModule §14 双层动画设计。
|
||
/// </summary>
|
||
public class SpringState : PlayerStateBase
|
||
{
|
||
public SpringState(PlayerController owner) : base(owner) { }
|
||
|
||
public override void OnStateEnter()
|
||
{
|
||
// 前摇开始时只扣除充能,不立即回血;回血在前摇结束后的 OnSpringEnd 中执行。
|
||
// 若前摇被打断(受伤 → HurtState),OnStateExit 被调用,充能已扣除但 OnSpringEnd 不会执行,回血失败。
|
||
bool used = Stats?.ConsumeSpringCharge() ?? false;
|
||
if (!used)
|
||
{
|
||
Owner.TransitionTo(Owner.GetState<IdleState>());
|
||
return;
|
||
}
|
||
|
||
// 停止移动
|
||
Move?.ZeroHorizontalVelocity();
|
||
|
||
// 在 Overlay Layer(Layer 1)播放灵泉动画,叠加于 Base Layer 的 Idle 之上
|
||
if (AnimCfg?.UseSpring != null)
|
||
{
|
||
var state = Owner.PlayOnOverlay(AnimCfg.UseSpring);
|
||
if (state != null)
|
||
{
|
||
state.Events(this).OnEnd = OnSpringEnd;
|
||
return;
|
||
}
|
||
}
|
||
|
||
// 无动画配置则直接结束(视为前摇瞬间完成)
|
||
OnSpringEnd();
|
||
}
|
||
|
||
public override void OnStateExit()
|
||
{
|
||
// 淡出叠加层,恢复纯 Base Layer 动画
|
||
Owner.StopOverlay(fadeDuration: 0.1f);
|
||
}
|
||
|
||
private void OnSpringEnd()
|
||
{
|
||
// 前摇正常结束 → 执行回血
|
||
Stats?.ApplySpringHeal();
|
||
Owner.TransitionTo(Owner.GetState<IdleState>());
|
||
}
|
||
}
|
||
}
|