Beispiel #1
0
        /// <summary>
        /// Checks spell ids to issue an attack.
        /// </summary>
        /// <param name="a_character">Character to pull stats from.</param>
        /// <param name="a_id">ID of the spell to add.</param>
        public static void IssueAttack(Entities.Character a_character, int a_id)
        {
            switch (a_id)
            {
            case 0:
                m_attacks.Add(new Attacks.Attack_Basic(m_sheet_attack, a_character));
                break;

            case 1:
                m_attacks.Add(new Attacks.Arcanebolt(m_sheet_arcane, a_character));
                break;

            case 2:
                m_attacks.Add(new Attacks.Fireball(m_sheet_fireball, a_character));
                break;

            case 3:
                m_attacks.Add(new Attacks.Viper(m_sheet_viper, a_character));
                break;

            case 4:
                m_attacks.Add(new Attacks.Nuke(m_sheet_nuke, a_character));
                break;

            case 5:
                m_attacks.Add(new Attacks.Hammer(m_sheet_hammer, a_character));
                break;

            case 6:
                m_attacks.Add(new Attacks.Lightning(m_sheet_lightning, a_character));
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Deals damage based on attacker and defender's stats. Returns the damage amount.
        /// </summary>
        /// <param name="a_attacker">Attacking character.</param>
        /// <param name="a_defender">Defending character.</param>
        /// <param name="a_isMelee">Set to false if this is a magic attack.</param>
        /// <param name="a_multiplier">Value to multiply damage by.</param>
        /// <returns></returns>
        static public int DealDamage(Entities.Character a_attacker, Entities.Character a_defender, bool a_isMelee, int a_multiplier)
        {
            int    result     = 0;
            int    attack     = a_attacker.GetTotalAttack();
            int    defense    = a_defender.GetTotalDefense();
            int    spellPower = a_attacker.GetTotalSpellpower();
            double percent    = attack / defense;

            if (a_isMelee)
            {
                /**To have a true "100%" attack, you must have double the enemy's defense.
                 * At equal attack and defense, you deal 50% of your actual damage.
                 **/
                if (attack > defense)
                {
                    if (percent >= 2)
                    {
                        result = rand.Next((int)(attack * .9), (int)(attack * 1.3));
                    }
                    else

                    {
                        result = rand.Next((int)((attack / percent) * .8), (int)((attack / percent) * 1.1));
                    }
                }
                else if (attack == defense)
                {
                    result = rand.Next((int)(attack / 2 * .8), (int)((attack / 2) * 1.2));
                }
                else //a_attacker.GetAttack() < a_defender.GetDefense())
                {
                    result = 1 + rand.Next((int)((attack / percent) * .8), (int)((attack / percent) * 1.1));
                }
                result *= a_multiplier;
            }
            else //Is a spell
            {
                result = (int)(spellPower * a_multiplier);
            }
            if (result < 1)
            {
                result = 1;
            }
            return(result);
        }