73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
using System.Collections;
|
|
using Animancer;
|
|
using BaseGames.Combat;
|
|
using UnityEngine;
|
|
|
|
namespace BaseGames.Enemies.Abilities
|
|
{
|
|
/// <summary>
|
|
/// 多段砸地能力:起手 → 循环砸地(N次,带 HitBox 激活)→ 收招。
|
|
/// 支持霸体(ABL SO 配置 interruptOnHurt=false),后摇时间可配置。
|
|
/// 可复用于任何多段地面攻击型敌人。
|
|
/// </summary>
|
|
public class RepeatSlamAbility : EnemyAbilityBase
|
|
{
|
|
[Header("打击")]
|
|
[SerializeField] private HitBox _hitBox;
|
|
|
|
private RepeatSlamAbilitySO _cfg;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
_cfg = ResolveConfig<RepeatSlamAbilitySO>();
|
|
}
|
|
|
|
protected override IEnumerator ExecuteCoroutine()
|
|
{
|
|
if (_cfg == null) yield break;
|
|
|
|
Phase = AbilityRunState.Active;
|
|
|
|
if (_cfg.startClip.Clip != null)
|
|
{
|
|
_animancer.Play(_cfg.startClip);
|
|
yield return EnemyAbilityWaits.Get(_cfg.startClip.Clip.length);
|
|
}
|
|
|
|
for (int i = 0; i < _cfg.slamCount; i++)
|
|
{
|
|
if (_cfg.loopClip.Clip != null)
|
|
{
|
|
_animancer.Play(_cfg.loopClip);
|
|
float preHit = Mathf.Max(0f, _cfg.loopClip.Clip.length - _cfg.hitActiveTime - 0.05f);
|
|
yield return EnemyAbilityWaits.Get(preHit);
|
|
}
|
|
|
|
var dmgSrc = _config?.attackSequence?.Length > 0 ? _config.attackSequence[0].damageSource : null;
|
|
_hitBox?.Activate(dmgSrc, _transform);
|
|
yield return EnemyAbilityWaits.Get(_cfg.hitActiveTime);
|
|
_hitBox?.Deactivate();
|
|
|
|
if (i < _cfg.slamCount - 1)
|
|
yield return EnemyAbilityWaits.Get(0.1f);
|
|
}
|
|
|
|
if (_cfg.endClip.Clip != null)
|
|
{
|
|
_animancer.Play(_cfg.endClip);
|
|
yield return EnemyAbilityWaits.Get(_cfg.endClip.Clip.length + _cfg.staggerDuration);
|
|
}
|
|
else
|
|
{
|
|
yield return EnemyAbilityWaits.Get(_cfg.staggerDuration);
|
|
}
|
|
}
|
|
|
|
protected override void OnInterrupted(InterruptReason reason)
|
|
{
|
|
_hitBox?.Deactivate();
|
|
}
|
|
}
|
|
}
|