70 lines
2.3 KiB
C#
70 lines
2.3 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 ClipTransition _strikeClip;
|
|
[SerializeField] private ClipTransition _loopClip;
|
|
[SerializeField] private ClipTransition _endClip;
|
|
|
|
[Header("碰撞")]
|
|
[SerializeField] private HitBox _attackHitBox;
|
|
[SerializeField] private HurtBox _hurtBox;
|
|
|
|
[Header("行为")]
|
|
[Tooltip("脆弱悬挂窗口持续时间(秒)")]
|
|
[SerializeField] private float _hangDuration = 2f;
|
|
|
|
protected override IEnumerator ExecuteCoroutine()
|
|
{
|
|
Phase = AbilityRunState.Active;
|
|
|
|
// 出击阶段:播放攻击动画并激活 HitBox
|
|
if (_strikeClip.Clip != null)
|
|
{
|
|
_animancer.Play(_strikeClip);
|
|
var dmgSrc = _config?.attackSequence?.Length > 0 ? _config.attackSequence[0].damageSource : null;
|
|
_attackHitBox?.Activate(dmgSrc, _transform);
|
|
yield return EnemyAbilityWaits.Get(_strikeClip.Clip.length);
|
|
}
|
|
_attackHitBox?.Deactivate();
|
|
|
|
// 脆弱悬挂阶段:HurtBox 激活为玩家反击窗口
|
|
if (_loopClip.Clip != null)
|
|
_animancer.Play(_loopClip);
|
|
|
|
if (_hurtBox != null)
|
|
_hurtBox.enabled = true;
|
|
|
|
yield return EnemyAbilityWaits.Get(_hangDuration);
|
|
|
|
if (_hurtBox != null)
|
|
_hurtBox.enabled = false;
|
|
|
|
// 收回阶段
|
|
if (_endClip.Clip != null)
|
|
{
|
|
_animancer.Play(_endClip);
|
|
yield return EnemyAbilityWaits.Get(_endClip.Clip.length);
|
|
}
|
|
}
|
|
|
|
protected override void OnInterrupted(InterruptReason reason)
|
|
{
|
|
_attackHitBox?.Deactivate();
|
|
if (_hurtBox != null)
|
|
_hurtBox.enabled = false;
|
|
}
|
|
}
|
|
}
|