Example #1
0
        /// <summary>
        /// Controls battle based on current stance.
        /// </summary>
        /// <param name="Stance"></param>
        public void SetStanceModifier(Ifight attacker, Ifight defender)
        {
            ItemWeapon attackerWeapon = attacker.EquippedWeapon as ItemWeapon;
            ItemArmor  attackerArmor  = attacker.EquippedArmor as ItemArmor;
            ItemArmor  defenderArmor  = defender.EquippedArmor as ItemArmor;

            double damage = 0;
            int    healthModifier;

            switch (Stance)
            {
            case BattleStance.ATTACK:
                if (attackerWeapon.WeaponDamageType == defenderArmor.ArmorResistanceType)
                {
                    damage = Math.Round(attackerWeapon.WeaponDamageAmount * defenderArmor.ArmorResistModifier);
                }
                else
                {
                    damage = attackerWeapon.WeaponDamageAmount;
                }
                break;

            case BattleStance.DEFEND:
                damage = 0;
                break;

            case BattleStance.FLEE:
                //GameViewModel.OnPlayerFlee();
                damage = 0;
                break;

            default:
                break;
            }

            NPC defenderHealth = defender as NPC;

            healthModifier = (int)damage;

            defenderHealth.Health = defenderHealth.Health - healthModifier;
            // Temporary: To be moved to a method in the Fighter NPC
            switch (healthModifier)
            {
            case 0:
                defender.Stance = BattleStance.ATTACK;
                break;

            case 35:
                defender.Stance = BattleStance.DEFEND;
                break;

            case 50:
                defender.Stance = BattleStance.FLEE;
                break;

            default:
                break;
            }
        }
Example #2
0
 public Fighter(int id, int hp, string name, string description, ItemArmor armor, ItemWeapon weapon, RaceType racetype, BattleStance initialStance, string imgDataPath)
     : base(id, hp, name, description, racetype, initialStance, imgDataPath)
 {
     _id            = id;
     _name          = name;
     _description   = description;
     _race          = racetype;
     Stance         = initialStance;
     _imageDataPath = imgDataPath;
     _health        = hp;
     EquippedWeapon = weapon;
     EquippedArmor  = armor;
 }
Example #3
0
 public Monger(int id, int hp, string name, string description, ItemArmor armor, ItemWeapon weapon, RaceType racetype, BattleStance initialStance, string imgDataPath)
     : base(id, hp, name, description, armor, weapon, racetype, initialStance, imgDataPath)
 {
     _id            = id;
     _name          = name;
     _description   = description;
     _race          = RaceType.Monger; // Has to be a Monger - silly to be anything else. :P
     Stance         = initialStance;
     _imageDataPath = imgDataPath;
     _health        = hp;
     EquippedArmor  = armor;
     EquippedWeapon = weapon;
 }
Example #4
0
        /// <summary>
        /// Controls battle based on current stance.
        /// </summary>
        /// <param name="Stance"></param>
        public void SetStanceModifier(Ifight attacker, Ifight defender)
        {
            ItemWeapon attackerWeapon = attacker.EquippedWeapon as ItemWeapon;
            ItemArmor  attackerArmor  = attacker.EquippedArmor as ItemArmor;
            ItemArmor  defenderArmor  = attacker.EquippedArmor as ItemArmor;

            double damage = 0;
            int    healthModifier;

            switch (Stance)
            {
            case BattleStance.ATTACK:
                if (attackerWeapon.WeaponDamageType == defenderArmor.ArmorResistanceType)
                {
                    damage = Math.Round(attackerWeapon.WeaponDamageAmount * defenderArmor.ArmorResistModifier);
                }
                else
                {
                    damage = attackerWeapon.WeaponDamageAmount;
                }
                break;

            case BattleStance.DEFEND:
                damage = 0;
                break;

            case BattleStance.FLEE:
                damage = 0;
                break;

            default:
                break;
            }

            Player defenderHealth = defender as Player;

            healthModifier = (int)damage;

            defenderHealth.Health = -healthModifier;
        }