/// <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_Class 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_Class 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_Class 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."; }
/// <summary> /// This Method updates the Equipment and Items Grids /// </summary> private void UpdateGrids() { Item_Grid.Rows.Clear(); Equipment_Grid.Rows.Clear(); foreach (var key in LIB.m_MainCharacterInfo.Item_List) { CLIB.Item_Class item = LIB.m_MainCharacterInfo.Items[key]; object[] param = { key, item.Cost, item.Weight, item.Description }; Item_Grid.Rows.Add(param); } foreach (var key in LIB.m_MainCharacterInfo.Weapon_List) { CLIB.Weapon_Class weapon = LIB.m_MainCharacterInfo.Weapons[key]; string properties = string.Join(", ", weapon.Properties.ToArray()); object[] param = { weapon.Equipped, "Weapon", key, weapon.Cost, weapon.Damage, string.Empty, weapon.Weight + " lb.", properties }; Equipment_Grid.Rows.Add(param); } foreach (var key in LIB.m_MainCharacterInfo.Armor_List) { CLIB.Armor_Class armor = LIB.m_MainCharacterInfo.Armor[key]; string properties = "Strength Required: " + armor.StrengthReq + Environment.NewLine + "Stealth Disadvantage: " + armor.Disadvantage; object[] param = { armor.Equipped, "Armor", key, armor.Cost, string.Empty, armor.ArmorClass, armor.Weight + " lb.", properties }; Equipment_Grid.Rows.Add(param); } }
private void PopulateGrid(Dictionary <string, CLIB.Item_Class> ItemDictionary) { BuyItems_Grid.Rows.Clear(); foreach (var key in ItemDictionary.Keys) { CLIB.Item_Class item = ItemDictionary[key]; if (item.Cost != string.Empty) { object[] param = { false, item.Style, key, item.Quantity, item.Cost, item.Weight + " lb.", item.Description }; BuyItems_Grid.Rows.Add(param); } } }
private void AddItemNode(string itemName, CLIB.Item_Class item) { var itemNode = new XElement(LC.Item, 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)); itemNodes.Add(itemNode); }
private void PopulateItems(XmlDocument xDoc) { XmlNode itemsNode = xDoc.GetElementsByTagName(LC.Items)[0]; XmlNodeList items = itemsNode.SelectNodes(LC.Item); foreach (XmlNode itemNode in items) { string name = itemNode.SelectSingleNode(LC.Name).InnerText; CLIB.Item_Class item = new CLIB.Item_Class { Cost = itemNode.SelectSingleNode(LC.Cost).InnerText, Weight = Convert.ToDouble(itemNode.SelectSingleNode(LC.Weight).InnerText), Description = itemNode.SelectSingleNode(LC.Description).InnerText }; m_ItemData.Add(name, item); } }
/// <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_Class 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_Class 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_Class armor = LIB.m_MainCharacterInfo.Armor[key]; LIB.m_MainCharacterInfo.CarryingWeight += armor.Weight * armor.Quantity; } }