Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-05-26 13:04:38 +08:00
parent f74d7f1877
commit 5a0f1548ea
53 changed files with 4853 additions and 163 deletions

View File

@@ -0,0 +1,66 @@
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();
}
}
}