71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using System.Collections;
|
|
using Animancer;
|
|
using BaseGames.Combat;
|
|
using UnityEngine;
|
|
|
|
namespace BaseGames.Enemies.Abilities
|
|
{
|
|
/// <summary>
|
|
/// 天花板三段攻击能力:出击 → 脆弱悬挂窗口 → 收回。
|
|
/// 悬挂阶段(_loopClip)为脆弱窗口:HurtBox 激活,等待 _hangDuration 后结束。
|
|
/// 可复用于任何固定位置的天花板攻击型敌人。
|
|
/// </summary>
|
|
public class CeilingHangStrikeAbility : EnemyAbilityBase
|
|
{
|
|
[Header("碰撞")]
|
|
[SerializeField] private HitBox _attackHitBox;
|
|
[SerializeField] private HurtBox _hurtBox;
|
|
|
|
private CeilingHangStrikeAbilitySO _cfg;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
_cfg = ResolveConfig<CeilingHangStrikeAbilitySO>();
|
|
}
|
|
|
|
protected override IEnumerator ExecuteCoroutine()
|
|
{
|
|
if (_cfg == null) yield break;
|
|
|
|
Phase = AbilityRunState.Active;
|
|
|
|
// 出击阶段:播放攻击动画并激活 HitBox
|
|
if (_cfg.strikeClip.Clip != null)
|
|
{
|
|
_animancer.Play(_cfg.strikeClip);
|
|
var dmgSrc = _config?.attackSequence?.Length > 0 ? _config.attackSequence[0].damageSource : null;
|
|
_attackHitBox?.Activate(dmgSrc, _transform);
|
|
yield return EnemyAbilityWaits.Get(_cfg.strikeClip.Clip.length);
|
|
}
|
|
_attackHitBox?.Deactivate();
|
|
|
|
// 脆弱悬挂阶段:HurtBox 激活为玩家反击窗口
|
|
if (_cfg.loopClip.Clip != null)
|
|
_animancer.Play(_cfg.loopClip);
|
|
|
|
if (_hurtBox != null)
|
|
_hurtBox.enabled = true;
|
|
|
|
yield return EnemyAbilityWaits.Get(_cfg.hangDuration);
|
|
|
|
if (_hurtBox != null)
|
|
_hurtBox.enabled = false;
|
|
|
|
// 收回阶段
|
|
if (_cfg.endClip.Clip != null)
|
|
{
|
|
_animancer.Play(_cfg.endClip);
|
|
yield return EnemyAbilityWaits.Get(_cfg.endClip.Clip.length);
|
|
}
|
|
}
|
|
|
|
protected override void OnInterrupted(InterruptReason reason)
|
|
{
|
|
_attackHitBox?.Deactivate();
|
|
if (_hurtBox != null)
|
|
_hurtBox.enabled = false;
|
|
}
|
|
}
|
|
}
|