public void takeDamage(float dmg, attributes.DamageType type)
    {
        float calculatedDamage = 0f;

        // calculate the total damage.
        switch (type)
        {
        case attributes.DamageType.Normal:
            calculatedDamage = -(myResistances.getArmor() * 0.01f - 1) * dmg;
            break;

        case attributes.DamageType.Fire:
            calculatedDamage = -(myResistances.getFireResistance() * 0.01f - 1) * dmg;
            break;

        case attributes.DamageType.Ice:
            calculatedDamage = -(myResistances.getIceResistance() * 0.01f - 1) * dmg;
            break;

        case attributes.DamageType.Lightning:
            calculatedDamage = -(myResistances.getLightningResistance() * 0.01f - 1) * dmg;
            break;
        }

        // do the damage.
        currentHealth -= calculatedDamage;

        if (currentHealth < 0f)
        {
            isDead        = true;
            currentHealth = 0f;
        }

        if (isPlayer)
        {
            GuiManager.UpdateHealthText(currentHealth, maxHealth);
        }
        instantiateFloatingText(calculatedDamage);
    }
Example #2
0
 public void ChangeDamageType(attributes.DamageType d)
 {
     bulletDamageType = d;
 }