static void LoadStoreStock(XmlNode Stock, Stores Store, string ErMsg) { foreach (XmlNode StockType in Stock) { int Count = 0; int ChildCount = StockType.ChildNodes.Count; switch (StockType.Name) { case "Weapons": Weapon[] WeapTemp = new Weapon[ChildCount]; foreach (XmlNode Weapon in StockType) { WeapTemp[Count] = new Weapon(); foreach (Weapon GOWeapon in GameObjects.Weapons) { if (GOWeapon.Name == Weapon.Name) { WeapTemp[Count] = GOWeapon; break; } } WeapTemp[Count].Cost = Weapon.ChildNodes.Count; Count++; } foreach (Weapon Weapon in WeapTemp) { Store.AddToWeaponStock(Weapon); } break; case "Armour": Armour[] ArmTemp = new Armour[ChildCount]; foreach (XmlNode Armour in StockType) { ArmTemp[Count] = new Armour(); foreach (Armour GOArmour in GameObjects.Armour) { if (GOArmour.Name == Armour.Name) { ArmTemp[Count] = GOArmour; break; } } ArmTemp[Count].Cost = Armour.ChildNodes.Count; Count++; } foreach (Armour Armour in ArmTemp) { Store.AddToArmourStock(Armour); } break; case "Potions": Potion[] PotTemp = new Potion[ChildCount]; foreach (XmlNode Potion in StockType) { PotTemp[Count] = new Potion(); foreach (Potion GOPotions in GameObjects.Potions) { if (GOPotions.Name == Potion.Name) { PotTemp[Count] = GOPotions; } } PotTemp[Count].Cost = Potion.ChildNodes.Count; Count++; } foreach (Potion Potion in PotTemp) { Store.AddToPotionStock(Potion); } break; default: Debug.Log(ErMsg + " - " + StockType.Name); break; } } }
public static void LoadGameObjects() { ClearGameObjects(); XmlDocument Doc = new XmlDocument(); Doc.Load("GameObjects.xml"); foreach (XmlNode Node in Doc.DocumentElement) { if (Node.Name == "Weapons") { int Count = 0; int ChildCount = Convert.ToInt32(Node.Attributes[0].Value); Weapon[] WeapTemp = new Weapon[ChildCount]; foreach (XmlNode Child in Node.ChildNodes) { WeapTemp[Count] = new Weapon(); WeapTemp[Count].Name = Child.Name; WeapTemp[Count].Damage = Convert.ToInt32(Child.Attributes[1].Value); WeapTemp[Count].TwoHanded = Convert.ToBoolean(Child.Attributes[2].Value); WeapTemp[Count].Versatile = Convert.ToBoolean(Child.Attributes[3].Value); WeapTemp[Count].Cost = Convert.ToInt32(Child.Attributes[4].Value); Count++; } foreach (Weapon Weapon in WeapTemp) { Weapons.Add(Weapon); } } else if (Node.Name == "Armour") { int Count = 0; int ChildCount = Convert.ToInt32(Node.Attributes[0].Value); Armour[] ArmTemp = new Armour[ChildCount]; foreach (XmlNode Child in Node.ChildNodes) { ArmTemp[Count] = new Armour(); ArmTemp[Count].Name = Child.Name; ArmTemp[Count].AC = Convert.ToInt32(Child.Attributes[1].Value); ArmTemp[Count].Weight = Child.Attributes[2].Value; ArmTemp[Count].Cost = Convert.ToInt32(Child.Attributes[3].Value); Count++; } foreach (Armour Arm in ArmTemp) { Armour.Add(Arm); } } else if (Node.Name == "Potions") { int Count = 0; int ChildCount = Convert.ToInt32(Node.Attributes[0].Value); Potion[] PotTemp = new Potion[ChildCount]; foreach (XmlNode Child in Node.ChildNodes) { PotTemp[Count] = new Potion(); PotTemp[Count].Name = Child.Attributes[0].Value; PotTemp[Count].DiceNum = Convert.ToInt32(Child.Attributes[1].Value); PotTemp[Count].DiceSize = Convert.ToInt32(Child.Attributes[2].Value); PotTemp[Count].Modifier = Convert.ToInt32(Child.Attributes[3].Value); } foreach (Potion Potion in PotTemp) { Potions.Add(Potion); } } else if (Node.Name == "Enemies") { int Count = 0; int ChildCount = Convert.ToInt32(Node.Attributes[0].Value); EnemyNPC[] EnmTemp = new EnemyNPC[ChildCount]; foreach (XmlNode Child in Node.ChildNodes) { EnmTemp[Count] = new EnemyNPC(); EnmTemp[Count].Name = Child.Name; EnmTemp[Count].HP = Convert.ToInt32(Child.Attributes[0].Value); EnmTemp[Count].MaxHP = EnmTemp[Count].HP; EnmTemp[Count].AC = Convert.ToInt32(Child.Attributes[1].Value); EnmTemp[Count].Str = Convert.ToInt32(Child.Attributes[2].Value); EnmTemp[Count].StrMod = Convert.ToInt32(Child.Attributes[3].Value); EnmTemp[Count].Dex = Convert.ToInt32(Child.Attributes[4].Value); EnmTemp[Count].DexMod = Convert.ToInt32(Child.Attributes[5].Value); EnmTemp[Count].Con = Convert.ToInt32(Child.Attributes[6].Value); EnmTemp[Count].ConMod = Convert.ToInt32(Child.Attributes[7].Value); EnmTemp[Count].Stamina = Convert.ToInt32(Child.Attributes[8].Value); EnmTemp[Count].StaminaMax = Convert.ToInt32(Child.Attributes[9].Value); EnmTemp[Count].DifBonus = Convert.ToInt32(Child.Attributes[10].Value); EnmTemp[Count].Weapon.UpdateWeaponString(Child.Attributes[11].Value); EnmTemp[Count].OffHand = Child.Attributes[12].Value; EnmTemp[Count].Armour.UpdateArmourString(Child.Attributes[13].Value); EnmTemp[Count].XPValue = Convert.ToInt32(Child.Attributes[14].Value); Count++; } foreach (EnemyNPC NPC in EnmTemp) { NPCs.Add(NPC); } } } }
public void AddToPotionStock(Potion Potion) { PotionStock.Add(Potion); }