コード例 #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
ファイル: Actor.cs プロジェクト: DarkKitsune/StarWander
 public void Damage(GameObject?attacker, double amount)
 {
     HealthPool.Damage(amount);
     LastDamagedBy = attacker;
     OnDamage(attacker, amount);
 }