67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
using System.Collections;
|
||
using Animancer;
|
||
using BaseGames.Combat;
|
||
using BaseGames.Core;
|
||
using BaseGames.Core.Pool;
|
||
using UnityEngine;
|
||
|
||
namespace BaseGames.Enemies
|
||
{
|
||
/// <summary>
|
||
/// E005 肥蛭(精英怪)。
|
||
/// 特性:
|
||
/// - 撕咬(MeleeVulnerabilityAbility)含后摇脆弱窗口
|
||
/// - 死亡两阶段:Death_Pre 无敌演出(含 AnimationEvent spawn_e003)→ base.Die()
|
||
/// </summary>
|
||
public class E005_FeiZhi : EnemyBase
|
||
{
|
||
[Header("死亡演出")]
|
||
[SerializeField] private ClipTransition _deathPreClip;
|
||
[SerializeField] private HurtBox _hurtBox;
|
||
[SerializeField] private float _deathPreDuration = 3f;
|
||
|
||
[Header("生成 E003(Death_Pre AnimationEvent 触发)")]
|
||
[SerializeField] private int _spawnCount = 3;
|
||
[SerializeField] private float _spawnRadius = 1.5f;
|
||
|
||
/// <summary>
|
||
/// Death_Pre 动画适当帧的 AnimationEvent 调用 SpawnProjectile("spawn_e003") 生成幼蛭。
|
||
/// </summary>
|
||
public override void SpawnProjectile(string payload)
|
||
{
|
||
if (payload != "spawn_e003") return;
|
||
|
||
var pool = BaseGames.Core.ServiceLocator.GetOrDefault<IObjectPoolService>();
|
||
if (pool == null) return;
|
||
|
||
for (int i = 0; i < _spawnCount; i++)
|
||
{
|
||
Vector2 offset = Random.insideUnitCircle * _spawnRadius;
|
||
pool.Spawn("ENM_YouZhi", (Vector2)transform.position + offset, Quaternion.identity);
|
||
}
|
||
}
|
||
|
||
protected override void Die()
|
||
{
|
||
StartCoroutine(DeathSequence());
|
||
}
|
||
|
||
private IEnumerator DeathSequence()
|
||
{
|
||
StopBehaviorTree();
|
||
StopMovement();
|
||
|
||
if (_hurtBox != null)
|
||
_hurtBox.enabled = false;
|
||
|
||
if (_deathPreClip.Clip != null)
|
||
{
|
||
Animancer.Play(_deathPreClip);
|
||
yield return new WaitForSeconds(_deathPreDuration);
|
||
}
|
||
|
||
base.Die();
|
||
}
|
||
}
|
||
}
|