示例#1
0
        /// <summary>
        /// This Method updates the Equipment and Items Grids
        /// </summary>
        private void UpdateGrids()
        {
            Item_Grid.Rows.Clear();
            Equipment_Grid.Rows.Clear();
            LIB.m_MainCharacterInfo.CarryingWeight = 0;
            foreach (var key in LIB.m_MainCharacterInfo.Items.Keys)
            {
                CLIB.Item item  = LIB.m_MainCharacterInfo.Items[key];
                object[]  param = { item.Style, key, item.Quantity, item.Cost, item.Weight + " lb.", item.Description };
                Item_Grid.Rows.Add(param);
            }

            foreach (var key in LIB.m_MainCharacterInfo.Weapons.Keys)
            {
                CLIB.Weapon weapon     = LIB.m_MainCharacterInfo.Weapons[key];
                string      properties = string.Join(", ", weapon.Properties.ToArray());
                object[]    param      = { weapon.Equipped, weapon.Style, key, weapon.Quantity, weapon.Cost, weapon.Damage, string.Empty, weapon.Weight + " lb.", properties };
                Equipment_Grid.Rows.Add(param);
            }

            foreach (var key in LIB.m_MainCharacterInfo.Armor.Keys)
            {
                CLIB.Armor armor      = LIB.m_MainCharacterInfo.Armor[key];
                string     properties = string.Format(LC.ArmorProperties, armor.StrengthReq, armor.Disadvantage);
                object[]   param      = { armor.Equipped, armor.Style, key, armor.Quantity, armor.Cost, string.Empty, armor.ArmorClass, armor.Weight + " lb.", properties };
                Equipment_Grid.Rows.Add(param);
            }
            CALC.CarryWeight();
            Carry_TextBox.Text = LIB.m_MainCharacterInfo.CarryingWeight + " / " + LIB.m_MainCharacterInfo.CarryingCapacity + " lb.";
        }
        private void GatherWeaponData(XmlDocument xDoc)
        {
            XmlNode     itemsNode = xDoc.GetElementsByTagName(LC.Items)[0];
            XmlNodeList weapons   = itemsNode.SelectNodes(LC.Weapon);

            foreach (XmlNode weaponNode in weapons)
            {
                string      name           = weaponNode.SelectSingleNode(LC.Name).InnerText;
                XmlNode     propertiesNode = weaponNode.SelectNodes(LC.Properties)[0];
                XmlNodeList propertyNodes  = propertiesNode.SelectNodes(LC.Property);

                List <string> properties = new List <string>();
                foreach (XmlNode property in propertyNodes)
                {
                    properties.Add(property.InnerText);
                }

                CLIB.Weapon weapon = new CLIB.Weapon
                {
                    Cost       = weaponNode.SelectSingleNode(LC.Cost).InnerText,
                    Damage     = weaponNode.SelectSingleNode(LC.Damage).InnerText,
                    Weight     = Convert.ToDouble(weaponNode.SelectSingleNode(LC.Weight).InnerText),
                    Style      = weaponNode.SelectSingleNode(LC.Style).InnerText,
                    Properties = properties,
                    Equipped   = Convert.ToBoolean(weaponNode.SelectSingleNode(LC.Equipped).InnerText),
                    Quantity   = Convert.ToInt32(weaponNode.SelectSingleNode(LC.Quantity).InnerText)
                };

                m_WeaponData.Add(name, weapon);
            }
        }
        /// <summary>
        /// This method calculates the characters carrying weight
        /// </summary>
        public static void CarryWeight()
        {
            LIB.m_MainCharacterInfo.CarryingWeight = 0;
            foreach (var key in LIB.m_MainCharacterInfo.Items.Keys)
            {
                CLIB.Item item = LIB.m_MainCharacterInfo.Items[key];
                LIB.m_MainCharacterInfo.CarryingWeight += item.Weight * item.Quantity;
            }

            foreach (var key in LIB.m_MainCharacterInfo.Weapons.Keys)
            {
                CLIB.Weapon weapon = LIB.m_MainCharacterInfo.Weapons[key];
                LIB.m_MainCharacterInfo.CarryingWeight += weapon.Weight * weapon.Quantity;
            }

            foreach (var key in LIB.m_MainCharacterInfo.Armor.Keys)
            {
                CLIB.Armor armor = LIB.m_MainCharacterInfo.Armor[key];
                LIB.m_MainCharacterInfo.CarryingWeight += armor.Weight * armor.Quantity;
            }
        }
示例#4
0
 private void PopulateGrid(Dictionary <string, CLIB.Armor> ArmorDictionary, Dictionary <string, CLIB.Weapon> WeaponDictionary)
 {
     BuyEquipment_Grid.Rows.Clear();
     if (ArmorDictionary.Keys.Count > 0)
     {
         foreach (var key in ArmorDictionary.Keys)
         {
             CLIB.Armor armor      = ArmorDictionary[key];
             string     properties = string.Format(LC.ArmorProperties, armor.StrengthReq, armor.Disadvantage);
             object[]   param      = { false, armor.Style, key, armor.Quantity, armor.Cost, string.Empty, armor.ArmorClass, armor.Weight + " lb.", properties };
             BuyEquipment_Grid.Rows.Add(param);
         }
     }
     if (WeaponDictionary.Keys.Count > 0)
     {
         foreach (var key in WeaponDictionary.Keys)
         {
             CLIB.Weapon weapon     = WeaponDictionary[key];
             string      properties = string.Join(", ", weapon.Properties.ToArray());
             object[]    param      = { false, weapon.Style, key, weapon.Quantity, weapon.Cost, weapon.Damage, string.Empty, weapon.Weight + " lb.", properties };
             BuyEquipment_Grid.Rows.Add(param);
         }
     }
 }
示例#5
0
        private void AddWeaponNode(string itemName, CLIB.Weapon item)
        {
            List <object> properties = new List <object>();

            foreach (var property in item.Properties)
            {
                properties.Add(new XElement(LC.Property, property));
            }

            var itemNode =
                new XElement(LC.Weapon,
                             new XElement(LC.Name, itemName),
                             new XElement(LC.Cost, item.Cost),
                             new XElement(LC.Weight, item.Weight),
                             new XElement(LC.Style, item.Style),
                             new XElement(LC.Description, item.Description),
                             new XElement(LC.Quantity, item.Quantity),
                             new XElement(LC.Damage, item.Damage),
                             new XElement(LC.Equipped, item.Equipped),
                             new XElement(LC.Properties,
                                          properties));

            itemNodes.Add(itemNode);
        }