This commit is contained in:
huadexuan committed 2026-09-06 19:42:29 +08:00
1 parent 5cd7a93c4a
commit 1476a089cb
108 files changed
+32073 -117261

No files matched your search

+39 -8
View File
@@ -223,6 +223,33 @@ public class UnitBase : MonoBehaviour
EnsureStatusEffectController().ApplyStun(duration);
}
public float ModifyIncomingDamage(float damage, GameObject attacker)
{
if (damage <= 0f)
{
return 0f;
}
if (unitSkill == null)
{
return damage;
}
return unitSkill.ModifyIncomingDamage(damage, attacker);
}
public bool ReceiveDamage(float damage, GameObject attacker = null)
{
WorldHealthBar healthBar = GetComponent<WorldHealthBar>();
if (healthBar == null)
{
return false;
}
healthBar.TakeDamage(ModifyIncomingDamage(damage, attacker));
return true;
}
//根据自身Tag找到敌对Tag
private string GetOpponentTag()
{
@@ -516,13 +543,12 @@ public class UnitBase : MonoBehaviour
private void ApplyDirectDamage(GameObject opponent)
{
WorldHealthBar healthBar = opponent.GetComponentInParent<WorldHealthBar>();
if (healthBar == null)
UnitBase targetUnit = opponent.GetComponentInParent<UnitBase>();
if (targetUnit == null || !targetUnit.ReceiveDamage(attackPower, gameObject))
{
return;
}
healthBar.TakeDamage(attackPower);
RegisterAttackHit();
}
@@ -533,13 +559,12 @@ public class UnitBase : MonoBehaviour
return;
}
WorldHealthBar healthBar = target.GetComponentInParent<WorldHealthBar>();
if (healthBar == null)
UnitBase targetUnit = target.GetComponentInParent<UnitBase>();
if (targetUnit == null || !targetUnit.ReceiveDamage(attackPower * Mathf.Max(0f, damageMultiplier), gameObject))
{
return;
}
healthBar.TakeDamage(attackPower * Mathf.Max(0f, damageMultiplier));
if (registerEnergy)
{
RegisterAttackHit();
@@ -578,13 +603,19 @@ public class UnitBase : MonoBehaviour
continue;
}
WorldHealthBar healthBar = opponent.GetComponentInParent<WorldHealthBar>();
UnitBase targetUnit = opponent.GetComponentInParent<UnitBase>();
if (targetUnit == null)
{
continue;
}
WorldHealthBar healthBar = targetUnit.GetComponent<WorldHealthBar>();
if (healthBar == null || !hitHealthBars.Add(healthBar))
{
continue;
}
healthBar.TakeDamage(damage);
targetUnit.ReceiveDamage(damage, gameObject);
}
if (registerEnergy)