Beispiel #1
0
 public Weapon[] GetEquippedWeapons()
 {   
     List<Weapon> wep = new List<Weapon>();
     if (IsWeaponEquipped)
     {
         if (!Slots[5].IsEmpty && Slots[5].Item.ItemClass == ItemClass.WEAPON)
         {
             wep.Add(Slots[5].Item as Weapon);
         }
         if (!Slots[6].IsEmpty && Slots[6].Item.ItemClass == ItemClass.WEAPON)
         {
             wep.Add(Slots[6].Item as Weapon);
         }
         Weapon[] tab = new Weapon[wep.Count];
         for (int i = 0; i < wep.Count; i++)
         {
             tab[i] = wep[i];
         }
         return tab;
     }
     return null;
 }
Beispiel #2
0
        private void GenerateItems(int amount)
        {
            string[] dataLine;
            string[] indexes;
            string name;
            List<Point> startingPosList = Map.GenerateListOfStartingLocations(_map.map);
            //generate misc items
            indexes = Item.GetIndexNames(Game.ItemsDataTable);
            for (int i = 0; i < amount; i++)
            {
                Point startingPos = Map.SelectRandomEmptyLocation(startingPosList);
                name = indexes[Game.rndGlobal.Next(0, indexes.Count())];
                dataLine = Game.ItemsDataTable[name];
                //generate random amount of gold
                if (dataLine[0] == "Gold")
                {
                    dataLine[2] = Game.rndGlobal.Next(1, 101).ToString();
                }
                Item item = new Item(dataLine);
                _map.addObjectAt(startingPos.X + 1, startingPos.Y + 5, item);
            }
            //generate armors
            indexes = Item.GetIndexNames(Game.ArmorsDataTable);
            for (int i = 0; i < amount; i++)
            {
                Point startingPos = Map.SelectRandomEmptyLocation(startingPosList);
                name = indexes[Game.rndGlobal.Next(0, indexes.Count())];
                dataLine = Game.ArmorsDataTable[name];
                
                Armor item = new Armor(dataLine);
                _map.addObjectAt(startingPos.X + 1, startingPos.Y + 5, item);
            }
            //generate weapons
            indexes = Item.GetIndexNames(Game.WeaponsDataTable);
            for (int i = 0; i < amount; i++)
            {
                Point startingPos = Map.SelectRandomEmptyLocation(startingPosList);
                name = indexes[Game.rndGlobal.Next(0, indexes.Count())];
                dataLine = Game.WeaponsDataTable[name];

                Weapon item = new Weapon(dataLine);
                _map.addObjectAt(startingPos.X + 1, startingPos.Y + 5, item);
            }
        }
Beispiel #3
0
 public int calculateWeaponDefenceBonus(WeaponProficiency wp, Weapon w)
 {
     if (wp == null)
     {
         return 0;
     }
     return Convert.ToInt16((float)w.DefenceBonus * (wp.Value / 100f));
 }
Beispiel #4
0
        private AttackResult CalculateAttackResults(Weapon weapon, int hand, LivingObject target)
        {
            int toHit;
            int RtoHit;
            int totalDamage = 0;
            int bonus = 0;
            int defence;
            string attackResult = "";
            string dmgTypeText = "";
            WeaponProficiency wp;
            DamageType dt;
            AttackResult Result = new AttackResult();

            //select damage type
            if(hand == 1)
            {
                if (SelectedRightWeaponDamage == 0)
                {
                    dmgTypeText = Game.Lang[StringName.PROTECTION_PIERCE_ABRV];
                    dt = DamageType.PIERCE;
                }
                else if (SelectedRightWeaponDamage == 1)
                {
                    dmgTypeText = Game.Lang[StringName.PROTECTION_CUT_ABRV];
                    dt = DamageType.CUT;
                }
                else
                {
                    dmgTypeText = Game.Lang[StringName.PROTECTION_BLUNT_ABRV];
                    dt = DamageType.BLUNT;
                }
            }
            else
            {
                if (SelectedLeftWeaponDamage == 0)
                {
                    dmgTypeText = Game.Lang[StringName.PROTECTION_PIERCE_ABRV];
                    dt = DamageType.PIERCE;
                }
                else if (SelectedLeftWeaponDamage == 1)
                {
                    dmgTypeText = Game.Lang[StringName.PROTECTION_CUT_ABRV];
                    dt = DamageType.CUT;
                }
                else
                {
                    dmgTypeText = Game.Lang[StringName.PROTECTION_BLUNT_ABRV];
                    dt = DamageType.BLUNT;
                }
            }
            
            //get weapon proficiency
            wp = GetWeaponProficiency(weapon.WeaponClass);
            //calculate toHit
            toHit = calculateToHit(wp);
            defence = ((Monster)target).Defence.actualValue;
            RtoHit = Math.Max(toHit - defence, 5);
            
            int roll = Dice.Roll("d100");
            if (roll <= RtoHit)
            {
                //hit
                int[] dmg = calculateMeleeDamage(wp, weapon);
                if (hand == 1)
                {
                    totalDamage = dmg[SelectedRightWeaponDamage];
                }
                else
                {
                    totalDamage = dmg[SelectedLeftWeaponDamage];
                }
                roll = Dice.Roll("d100");
                if (roll > 50)
                {
                    bonus = roll - 50;
                }
                else if (roll < 50)
                {
                    bonus = roll - 50;
                }
                totalDamage += bonus;
                if (totalDamage < 0)
                {
                    totalDamage = 0;
                }
                attackResult = Game.Lang[StringName.ATTACK_ANDDEALT_TEXT] + totalDamage + " " + dmgTypeText + Game.Lang[StringName.ATTACK_DAMAGE_TEXT];
            }
            else
            {
                //miss
                attackResult = Game.Lang[StringName.ATTACK_MISSED_TEXT];
            }
            bool isDead = target.takeDamage(totalDamage, dt);
            if (isDead)
            {
                attackResult = Game.Lang[StringName.ATTACK_KILLED_TEXT];
            }
            Result.Text = attackResult;
            Result.IsKilled = isDead;
            return Result;
        }
Beispiel #5
0
        public int[] calculateRangedDamage(WeaponProficiency wp, Weapon w)
        {
            int[] dmg = new int[3];
            dmg[0] = w.RangeDamage[0];
            dmg[1] = w.RangeDamage[1];
            dmg[2] = w.RangeDamage[2];

            for (int i = 0; i < dmg.GetLength(0); i++)
            {
                if (dmg[i] == 0)
                {
                    //do not calcualte dmg if base dmg is 0
                    continue;
                }
                if (wp != null)
                {
                    dmg[i] = Convert.ToInt16((float)dmg[i] * (wp.Value / 100f)) + Convert.ToInt16(Math.Round(Stat[PrimaryStats.STRENGTH].currentValue / 4f));
                }
                else
                {
                    dmg[i] = Convert.ToInt16(Math.Round(Stat[PrimaryStats.STRENGTH].currentValue / 4f));
                }
                
            }

            return dmg;
        }