Exemple #1
0
        private static void LoadWeaponsFromMonsterNode(XmlNode monsterNode, Monster monsterType)
        {
            XmlNodeList weaponNodes = monsterNode.SelectNodes("./Weapons/WeaponID");

            if (weaponNodes != null)
            {
                foreach (XmlNode weaponNode in weaponNodes)
                {
                    monsterType.AddWeaponToWeapons(
                        WeaponFactory.CreateWeapon(weaponNode.GetXmlAttributeAsInt("ID")));
                }
            }
        }
Exemple #2
0
        private static void LoadTradersFromNodes(XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                Trader trader =
                    new Trader(node.GetXmlAttributeAsInt("ID"),
                               node.SelectSingleNode("./Name")?.InnerText ?? "",
                               node.GetXmlAttributeAsBool("HasWeapons"));

                foreach (XmlNode childNode in node.SelectNodes("./InventoryItems/Item"))
                {
                    trader.AddItemToInventory(ItemFactory.CreateGameItem(childNode.GetXmlAttributeAsInt("ID")),
                                              childNode.GetXmlAttributeAsInt("Quantity"));
                }

                foreach (XmlNode childNode in node.SelectNodes("./Weapons/Weapon"))
                {
                    trader.AddWeaponToWeapons(WeaponFactory.CreateWeapon(childNode.GetXmlAttributeAsInt("ID")));
                }

                AddTraderToList(trader);
            }
        }