/////////////////////////////////////////////////////////////////////////////////////
    //void TakeDamage(CharacterData.CharacterEntry, int float, bool                    //
    //Takes damage using the appropriate stats                                         //
    //CharacterData.CharacterEntry other - The CharacterEntry representing the attacker//
    //int otherWeapon - The attacker's weapon attack                                   //
    //float attackBase - The base attack multiplier of the attack                      //
    //bool isMagical - is the attack magical?                                          //
    /////////////////////////////////////////////////////////////////////////////////////
    public void TakeDamage(CharacterData.CharacterEntry other, float attackBase, bool isMagical)
    {
        int damage;

        if (isMagical)
        {
            damage = DamageCalculator.CalculateMagicalDamage(other.GetMATK(), attackBase, stats.enemyMDEF);
        }

        else
        {
            damage = DamageCalculator.CalculatePhysicalDamage(other.GetATK(), attackBase, stats.enemyDEF);
        }

        currentHP -= damage;
        Debug.Log("Damage Taken: " + damage);

        if (currentHP < 0)
        {
            currentHP = 0;
        }

        if (currentHP == 0)
        {
            Debug.Log("Enemy Defeated!");
        }
    }
Esempio n. 2
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //void TakeDamage(EnemyEntry, float, bool)                                                                           //
    //Calculates damage from an enemy attack                                                                             //
    //For balancing difficulty, I am considering allowing only certain enemies to crit, so LUCK is not considered for now//
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void TakeDamage(EnemyEntry otherStats, float baseDamage, bool isMagical)
    {
        if (iframesTimer < iframes)
        {
            //iframes are active, take no damage//
            return;
        }

        int damage = 0;

        if (DamageCalculator.Hits(stats.GetAGI(), otherStats.enemyAGI))
        {
            if (isMagical)
            {
                damage = DamageCalculator.CalculateMagicalDamage(otherStats.enemyMATK, baseDamage, stats.GetMDEF());
            }

            else
            {
                damage = DamageCalculator.CalculatePhysicalDamage(otherStats.enemyATK, baseDamage, stats.GetDEF());
            }
        }

        currentHP -= damage;

        if (currentHP <= 0)
        {
            currentHP = 0;
            HandleDeath();
        }

        iframesTimer = 0;
    }