Files
zeling_v2/Assets/_Game/Scripts/Player/States/SpringState.cs
Joywayer b7baf7ad6a Add WeaponFeedback component and AddressableManagerWindow meta file
- Implemented WeaponFeedback class for handling weapon-related feedbacks such as hit effects and attack sounds.
- Added meta file for AddressableManagerWindow to manage addressable assets.
- Included a new jump.data file for profiler data.
2026-05-22 22:03:32 +08:00

59 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace BaseGames.Player.States
{
/// <summary>
/// 使用灵泉(治疗)状态(架构 05_PlayerModule §2
/// 消耗 SpringCharge播放治愈动画动画结束后回到 Idle。
/// 需在地面且有充能才能进入PlayerController 负责条件检查)。
///
/// 动画在 Overlay LayerLayer 1播放叠加于 Base Layer 的 Idle/Run 之上,
/// 符合架构 05_PlayerModule §14 双层动画设计。
/// </summary>
public class SpringState : PlayerStateBase
{
public SpringState(PlayerController owner) : base(owner) { }
public override void OnStateEnter()
{
// 前摇开始时只扣除充能,不立即回血;回血在前摇结束后的 OnSpringEnd 中执行。
// 若前摇被打断(受伤 → HurtStateOnStateExit 被调用,充能已扣除但 OnSpringEnd 不会执行,回血失败。
bool used = Stats?.ConsumeSpringCharge() ?? false;
if (!used)
{
Owner.TransitionTo(Owner.GetState<IdleState>());
return;
}
// 停止移动
Move?.ZeroHorizontalVelocity();
// 在 Overlay LayerLayer 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();
Feedback.PlayHeal();
Owner.TransitionTo(Owner.GetState<IdleState>());
}
}
}