private static void LoadRecipesFromNodes(XmlNodeList nodes) { if (nodes == null) { return; } foreach (XmlNode node in nodes) { Recipe recipe = new Recipe(node.AttributeAsInt("ID"), node.SelectSingleNode("./Name")?.InnerText ?? ""); foreach (XmlNode childNode in node.SelectNodes("./Ingredients/Item")) { recipe.AddIngredient(childNode.AttributeAsInt("ID"), childNode.AttributeAsInt("Quantity")); } foreach (XmlNode childNode in node.SelectNodes("./OutputItems/Item")) { recipe.AddOutputItem(childNode.AttributeAsInt("ID"), childNode.AttributeAsInt("Quantity")); } _recipes.Add(recipe); } }
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); } }
static RecipeFactory() { Recipe granolaBar = new Recipe(1, "Granola bar"); granolaBar.AddIngredient(3001, 1); granolaBar.AddIngredient(3002, 1); granolaBar.AddIngredient(3003, 1); granolaBar.AddOutputItem(2001, 1); _recipes.Add(granolaBar); }
static RecipeFactory() { Recipe granolaBar = new Recipe(1, "Cereálie", "Po pozření doplní 4 HP a 40 Many. Ingredience: 1 Rozinky, 1 Oves, 1 Med"); granolaBar.AddIngredient(3001, 1); granolaBar.AddIngredient(3002, 1); granolaBar.AddIngredient(3003, 1); granolaBar.AddOutputItem(2001, 1); _recipes.Add(granolaBar); }
static RecipeFactory() { Recipe strongPotion = new Recipe(1, "Strong Potion"); strongPotion.AddIngredient(2001, 1); strongPotion.AddIngredient(3001, 1); strongPotion.AddIngredient(3002, 1); strongPotion.AddOutputItem(2002, 1); _recipes.Add(strongPotion); }
static RecipeFactory() { Recipe legendarySword = new Recipe(1, "Legendary Sword"); legendarySword.AddIngredient(3000, 1); legendarySword.AddIngredient(3001, 1); legendarySword.AddIngredient(3002, 1); legendarySword.AddOutputItem(1005, 1); Recipe prisonKey = new Recipe(2, "Prison Key"); prisonKey.AddIngredient(3003, 1); prisonKey.AddIngredient(3004, 1); prisonKey.AddIngredient(3005, 1); prisonKey.AddOutputItem(9001, 1); _recipes.Add(legendarySword); _recipes.Add(prisonKey); }