public static int GetMissionPrice(int id) { for (int i = 0; i < missions.Count; i++) { MissionModel mission = missions[i]; if (mission.id == id) { return(mission.price); } } return(-1); }
private static void GenerateList() { try { XmlDocument document = new XmlDocument(); document.Load(path); for (XmlNode PrimaryNode = document.FirstChild; PrimaryNode != null; PrimaryNode = PrimaryNode.NextSibling) { if ("list".Equals(PrimaryNode.Name)) { for (XmlNode SecundaryNode = PrimaryNode.FirstChild; SecundaryNode != null; SecundaryNode = SecundaryNode.NextSibling) { XmlNamedNodeMap itemMap = SecundaryNode.Attributes; if ("mission".Equals(SecundaryNode.Name)) { MissionModel mission = new MissionModel { id = int.Parse(itemMap.GetNamedItem("id").Value), price = int.Parse(itemMap.GetNamedItem("price").Value) }; bool enable = bool.Parse(itemMap.GetNamedItem("enable").Value); uint flag = (uint)(1 << mission.id); int listId = (int)Math.Ceiling(mission.id / 32.0); if (enable) { if (listId == 1) { missionPage1 += flag; } else if (listId == 2) { missionPage2 += flag; } } missions.Add(mission); } } } } } catch (Exception ex) { Logger.Exception(ex); } }