예제 #1
0
    public void damage(int damage_, int damageType)
    {
        int remainingDamage = damage_;

        if (shields > 0)
        {
            int shieldDamage = DamageTypes.damageShields(damage_, damageType);
            remainingDamage -= shieldDamage;
            shields          = Math.Max(0, shields - shieldDamage);
            if (shields == 0)
            {
                // Shield Gate
                if (damageType != DamageTypes.WARPING)
                {
                    remainingDamage -= maxShields;
                }
            }
        }
        if (remainingDamage <= 0)
        {
            return;
        }

        if (armor > 0)
        {
            int armorDamage = DamageTypes.damageArmor(damage_, damageType);
            remainingDamage -= armorDamage;
            armor            = Math.Max(0, armor - armorDamage);
        }
        if (remainingDamage <= 0)
        {
            return;
        }

        if (health > 0)
        {
            int healthDamage = DamageTypes.damageHealth(damage_, damageType);
            health = Math.Max(0, health - healthDamage);
        }
        if (health == 0)
        {
            // Kill unit
            Destroy(gameObject);
        }
    }