Esempio n. 1
0
        private static void LoadRecipesFromNodes(XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                Recipe recipe =
                    new Recipe(node.GetXmlAttributeAsInt("ID"),
                               node.SelectSingleNode("./Name")?.InnerText ?? "");

                foreach (XmlNode childNode in node.SelectNodes("./Ingredients/Item"))
                {
                    recipe.AddIngredient(childNode.GetXmlAttributeAsInt("ID"),
                                         childNode.GetXmlAttributeAsInt("Quantity"));
                }

                foreach (XmlNode childNode in node.SelectNodes("./Ingredients/Weapon"))
                {
                    recipe.AddWeaponIngredient(childNode.GetXmlAttributeAsInt("ID"));
                }
                foreach (XmlNode childNode in node.SelectNodes("./OutputItems/Item"))
                {
                    recipe.AddOutputItem(childNode.GetXmlAttributeAsInt("ID"),
                                         childNode.GetXmlAttributeAsInt("Quantity"));
                }

                foreach (XmlNode childNode in node.SelectNodes("./OutputItems/Weapon"))
                {
                    recipe.AddOutputWeapon(childNode.GetXmlAttributeAsInt("ID"));
                }

                AddRecipeToList(recipe);
            }
        }