(client) feat:实现健康状态定义,实现事件定义
This commit is contained in:
@ -32,6 +32,12 @@ namespace Entity
|
||||
|
||||
public EntityPrefab entityPrefab;
|
||||
public EntityDef entityDef;
|
||||
/// <summary>
|
||||
/// 手上拿着显示的贴图
|
||||
/// </summary>
|
||||
public GameObject weaponAnimator;
|
||||
|
||||
public ITick[] weaponAnimatorNodeList;
|
||||
|
||||
/// <summary>
|
||||
/// 人工智能行为树,定义实体的行为逻辑。
|
||||
@ -183,13 +189,32 @@ namespace Entity
|
||||
this.entityDef = entityDef;
|
||||
|
||||
HideHealthBar();
|
||||
InitWeaponAnimator();
|
||||
}
|
||||
|
||||
protected virtual void InitWeaponAnimator()
|
||||
{
|
||||
for (var i = 0; i < weaponAnimator.transform.childCount; i++)
|
||||
{
|
||||
Destroy(weaponAnimator.transform.GetChild(i).gameObject);
|
||||
weaponAnimatorNodeList = null;
|
||||
}
|
||||
var weapon = GetCurrentWeapon();
|
||||
if (weapon == null)
|
||||
{
|
||||
weaponAnimator.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var weaponAnimation = weapon.InstantiateAttackAnimation(weaponAnimator.transform);
|
||||
weaponAnimatorNodeList = weaponAnimation.animationComponents;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化实体的身体部分,包括不同朝向下的绘图节点。
|
||||
/// </summary>
|
||||
/// <param name="drawingOrder">绘制顺序定义。</param>
|
||||
public virtual void InitBody(DrawingOrderDef drawingOrder)
|
||||
protected virtual void InitBody(DrawingOrderDef drawingOrder)
|
||||
{
|
||||
// 预缓存枚举值(避免每次循环重复调用 Enum.GetValues)
|
||||
var states = Enum.GetValues(typeof(EntityState)).Cast<EntityState>().ToArray();
|
||||
@ -295,7 +320,7 @@ namespace Entity
|
||||
/// <param name="drawNode">绘图节点定义。</param>
|
||||
/// <param name="parent">父节点对象。</param>
|
||||
/// <returns>创建的GameObject,如果失败则返回null</returns>
|
||||
public virtual GameObject InitBodyPart(DrawNodeDef drawNode, GameObject parent)
|
||||
protected virtual GameObject InitBodyPart(DrawNodeDef drawNode, GameObject parent)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -470,6 +495,13 @@ namespace Entity
|
||||
}
|
||||
}
|
||||
|
||||
if (weaponAnimatorNodeList != null)
|
||||
{
|
||||
foreach (var tick in weaponAnimatorNodeList)
|
||||
{
|
||||
tick.Tick();
|
||||
}
|
||||
}
|
||||
if (IsShowingHealthBarUI)
|
||||
{
|
||||
_hitBarUIShowTimer -= Time.deltaTime;
|
||||
|
Reference in New Issue
Block a user