Files
zeling_v2/Assets/_Game/Scripts/Enemies/E005_FeiZhi.cs

67 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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("生成 E003Death_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();
}
}
}