完善盾卫技能

This commit is contained in:
huadexuan committed 2026-10-11 22:56:46 +08:00
1 parent 195a459c76
commit 9572db06ad
41 files changed
+25241 -351

No files matched your search

+13 -2
View File
@@ -69,8 +69,8 @@ public class WorldHealthBar : MonoBehaviour
public bool IsEnergyFull => !isDead && currentEnergy >= maxEnergy;
// 血条相对于单位头顶的额外高度。
[Min(0f)] public float heightOffset = 0.25f;
// 血条相对于单位头顶的额外高度。增加高度偏移避免遮挡角色头部。
[Min(0f)] public float heightOffset = 0.65f;
// 所有单位使用统一的血条世界宽度。
[Min(0.1f)] public float barWidth = 1.2f;
@@ -179,6 +179,13 @@ public class WorldHealthBar : MonoBehaviour
{
fillImage.color = GetHealthFillColor();
}
// 自动同步 UnitBase 上的等级设置
UnitBase unit = GetComponent<UnitBase>();
if (unit != null)
{
SetLevel(unit.level);
}
}
// 每帧让血条保持在单位头顶,并朝向主摄像机。
@@ -238,6 +245,9 @@ public class WorldHealthBar : MonoBehaviour
}
}
/// <summary>护盾吸收伤害事件:参数为实际吸收的伤害数值</summary>
public System.Action<float> OnShieldAbsorbedDamage;
// 让单位受到伤害,并弹出伤害数字。
// attacker: 攻击者,用于判断受击者(自己)是敌是友,决定数字颜色和浮动方向
public void TakeDamage(float amount, GameObject attacker = null)
@@ -252,6 +262,7 @@ public class WorldHealthBar : MonoBehaviour
currentShield -= absorbed;
amount -= absorbed;
UpdateShieldFill();
OnShieldAbsorbedDamage?.Invoke(absorbed);
Debug.Log($"{gameObject.name} 护盾吸收了 {absorbed:F1} 伤害,剩余护盾: {currentShield:F1}");
}