private static void PersistEnemyHealth(HealthPool oldHealth, HealthPool newHealth) { if (oldHealth.Health < oldHealth.MaxHealth) { newHealth.Damage(oldHealth.MaxHealth - oldHealth.Health); } }
// ***************************************************************************************************************** // When a collision interaction starts involving this game object... void OnCollisionEnter2D(Collision2D _collision) { // Check if the other collider that we hit has a HealthPool on it HealthPool healthPool = _collision.collider.GetComponent <HealthPool>(); if (healthPool != null) { // Apply damage to the health pool healthPool.Damage(m_damage, m_targetType); } }
public void Damage(GameObject?attacker, double amount) { HealthPool.Damage(amount); LastDamagedBy = attacker; OnDamage(attacker, amount); }