Пример #1
0
 private static void PersistEnemyHealth(HealthPool oldHealth, HealthPool newHealth)
 {
     if (oldHealth.Health < oldHealth.MaxHealth)
     {
         newHealth.Damage(oldHealth.MaxHealth - oldHealth.Health);
     }
 }
Пример #2
0
    // *****************************************************************************************************************
    // 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);
        }
    }
Пример #3
0
 public void Damage(GameObject?attacker, double amount)
 {
     HealthPool.Damage(amount);
     LastDamagedBy = attacker;
     OnDamage(attacker, amount);
 }