多轮审查和修复
This commit is contained in:
55
Assets/Scripts/Player/States/SpringState.cs
Normal file
55
Assets/Scripts/Player/States/SpringState.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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()
|
||||
{
|
||||
// 消耗灵泉充能并治疗(PlayerStats.UseSpring 内部回复 HP)
|
||||
bool used = Stats?.UseSpring() ?? 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()
|
||||
{
|
||||
Owner.TransitionTo(Owner.GetState<IdleState>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user