示例#1
0
    private int CalculateResistedDamage(int rawDamageAmount, BattleUtils.DamageTypes damageType)
    {
        TypeResistance resistType = null;

        foreach (TypeResistance resType in typeResistances)
        {
            if (resType.damageType == damageType)
            {
                resistType = resType;
            }
        }

        if (resistType == null)
        {
            Debug.Log("NO RESISTANCE SET FOR TYPE: " + damageType.ToString());
            resistType = new TypeResistance(damageType, 0);
        }
        float resistancePercent = resistType.resistanceAmount / 100.0f;
        float damageResisted    = rawDamageAmount * resistancePercent;
        float actualDamage      = rawDamageAmount - damageResisted;

        return((int)actualDamage);
    }
示例#2
0
    public void TakeDamage(int damageAmount, BattleUtils.AttackTypes attackType, BattleUtils.DamageTypes damageType)
    {
        int attackRoll = Random.Range(0, 100);

        if (attackType == BattleUtils.AttackTypes.physical)
        {
            if (GetPhysicalDodge() > attackRoll)
            {
                // FIXME: Indicate the attack was dodged
                Debug.Log("Physical attack was dodged");
            }
        }
        else if (attackType == BattleUtils.AttackTypes.magical)
        {
            if (GetMagicalDodge() > attackRoll)
            {
                // FIXME: Indicate attack was dodged
                Debug.Log("Magical attack was dodged");
            }
        }
        int actualDamage = CalculateResistedDamage(damageAmount, damageType);

        currentHitPoints -= actualDamage;
    }
示例#3
0
 public TypeResistance(BattleUtils.DamageTypes damageType, int resistanceAmount)
 {
     this.damageType       = damageType;
     this.resistanceAmount = resistanceAmount;
 }