feat(animation): 敌人侧动画事件补接无敌帧与反馈四件

EnableIFrame/DisableIFrame → HurtBox.SetInvincible(与玩家侧同形态,
无敌时长由动画时间轴上两事件间距表达);TriggerFeedback/PlaySFX →
IFeedbackPlayer,用于音效预警。此前敌人侧只接了 7/20 个事件类型。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-30 14:20:47 +08:00
co-authored by Claude Opus 5
parent 5cc93483d3
commit c05583a365
@@ -2,6 +2,7 @@ using System;
using Animancer; using Animancer;
using BaseGames.Combat; using BaseGames.Combat;
using BaseGames.Enemies; using BaseGames.Enemies;
using BaseGames.Feedback;
using UnityEngine; using UnityEngine;
namespace BaseGames.Animation namespace BaseGames.Animation
@@ -9,10 +10,10 @@ namespace BaseGames.Animation
/// <summary> /// <summary>
/// 敌人动画事件接收器(架构 §AnimationModule)。 /// 敌人动画事件接收器(架构 §AnimationModule)。
/// 挂载于敌人 Prefab 根节点。负责将 Animancer 动画时间点回调路由到 /// 挂载于敌人 Prefab 根节点。负责将 Animancer 动画时间点回调路由到
/// HitBox 激活、弹幕生成、嘶吼状态、二阶段切换等系统。 /// HitBox 激活、弹幕生成、嘶吼状态、二阶段切换、无敌帧、反馈等系统。
/// ///
/// 使用方式: /// 使用方式:
/// 1. 在 Inspector 中填充 _hitBoxes、_enemy。 /// 1. 在 Inspector 中填充 _hitBoxes、_hurtBox、_enemy。
/// 2. 将每条 ClipTransition + AnimationEventConfigSO 配对添加到 _bindings。 /// 2. 将每条 ClipTransition + AnimationEventConfigSO 配对添加到 _bindings。
/// 3. Awake 中 AnimationEventBinder.Bind 自动完成注入。 /// 3. Awake 中 AnimationEventBinder.Bind 自动完成注入。
/// </summary> /// </summary>
@@ -30,16 +31,23 @@ namespace BaseGames.Animation
[Header("子系统引用")] [Header("子系统引用")]
[SerializeField] private HitBox[] _hitBoxes; [SerializeField] private HitBox[] _hitBoxes;
[SerializeField] private HurtBox _hurtBox;
[SerializeField] private EnemyBase _enemy; [SerializeField] private EnemyBase _enemy;
[Header("事件绑定(每个 Clip 对应一个配置资产)")] [Header("事件绑定(每个 Clip 对应一个配置资产)")]
[SerializeField] private EventBinding[] _bindings; [SerializeField] private EventBinding[] _bindings;
private IFeedbackPlayer _feedback;
private void Awake() private void Awake()
{ {
if (_enemy == null) if (_enemy == null)
_enemy = GetComponentInParent<EnemyBase>(); _enemy = GetComponentInParent<EnemyBase>();
// IFeedbackPlayer 由父层或同层实现(EnemyFeedback / NullFeedbackPlayer),与玩家侧同写法
_feedback = GetComponentInParent<IFeedbackPlayer>()
?? NullFeedbackPlayer.Instance;
foreach (var b in _bindings) foreach (var b in _bindings)
AnimationEventBinder.Bind(b.clip, b.config, this); AnimationEventBinder.Bind(b.clip, b.config, this);
} }
@@ -59,6 +67,16 @@ namespace BaseGames.Animation
SetHitBoxActive(payload, false); SetHitBoxActive(payload, false);
break; break;
// ── 无敌帧 ────────────────────────────────────────────────
// 时长由动画时间轴上两个事件的间距表达,不在代码里写常量。
case AnimationEventType.EnableIFrame:
_hurtBox?.SetInvincible(true);
break;
case AnimationEventType.DisableIFrame:
_hurtBox?.SetInvincible(false);
break;
// ── 弹幕 / 技能 ─────────────────────────────────────────── // ── 弹幕 / 技能 ───────────────────────────────────────────
case AnimationEventType.SpawnProjectile: case AnimationEventType.SpawnProjectile:
_enemy?.SpawnProjectile(payload); _enemy?.SpawnProjectile(payload);
@@ -78,6 +96,18 @@ namespace BaseGames.Animation
_enemy?.TriggerPhaseTwo(); _enemy?.TriggerPhaseTwo();
break; break;
// ── 通用反馈 ──────────────────────────────────────────────
// 音效预警:在起手帧播一段可辨识的音,让玩家提前缩小招式可能性。
case AnimationEventType.TriggerFeedback:
if (!string.IsNullOrEmpty(payload))
_feedback.TriggerPreset(payload);
break;
case AnimationEventType.PlaySFX:
if (!string.IsNullOrEmpty(payload))
_feedback.PlaySFXById(payload);
break;
// ── 状态机钩子 ──────────────────────────────────────────── // ── 状态机钩子 ────────────────────────────────────────────
case AnimationEventType.AnimationComplete: case AnimationEventType.AnimationComplete:
_enemy?.OnAnimationComplete(payload); _enemy?.OnAnimationComplete(payload);