public int CompareTo(Object obj) { //Check for null and compare run-time types. if ((obj == null)) { return(1); } else if (!this.GetType().Equals(obj.GetType())) { if (obj.GetType() == typeof(string)) { return(this.GetKey().CompareTo(obj)); } return(this.ToString().CompareTo(obj.ToString())); } else { RemnantItem rItem = (RemnantItem)obj; if (this.ItemMode != rItem.ItemMode) { return(this.ItemMode.CompareTo(rItem.ItemMode)); } return(this.itemKey.CompareTo(rItem.GetKey())); } }
public void setMissingItems(RemnantCharacter charData) { List <RemnantItem> missingItems = new List <RemnantItem>(); List <RemnantItem> possibleItems = this.getPossibleItems(); foreach (RemnantItem item in possibleItems) { if (!charData.Inventory.Contains(item.GetKey())) { missingItems.Add(item); } } mItems = missingItems; if (possibleItems.Count == 0 && !GameInfo.Events.ContainsKey(this.getKey()) && !this.getKey().Equals("TraitBook") && !this.getKey().Equals("Simulacrum")) { RemnantItem ri = new RemnantItem("/UnknownPotentialLoot"); mItems.Add(ri); } }
public override bool Equals(Object obj) { //Check for null and compare run-time types. if ((obj == null)) { return(false); } else if (!this.GetType().Equals(obj.GetType())) { if (obj.GetType() == typeof(string)) { return(this.GetKey().Equals(obj)); } return(false); } else { RemnantItem rItem = (RemnantItem)obj; return(this.GetKey().Equals(rItem.GetKey()) && this.ItemMode == rItem.ItemMode); } }
public static void RefreshGameInfo() { zones.Clear(); eventItem.Clear(); subLocations.Clear(); mainLocations.Clear(); string eventName = null; string itemMode = null; string itemNotes = null; List <RemnantItem> eventItems = new List <RemnantItem>(); XmlTextReader reader = new XmlTextReader("GameInfo.xml"); reader.WhitespaceHandling = WhitespaceHandling.None; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name.Equals("Event")) { eventName = reader.GetAttribute("name"); } else if (reader.Name.Equals("Item")) { itemMode = reader.GetAttribute("mode"); itemNotes = reader.GetAttribute("notes"); } else if (reader.Name.Equals("Zone")) { zones.Add(reader.GetAttribute("name")); } else if (reader.Name.Equals("SubLocation")) { subLocations.Add(reader.GetAttribute("eventName"), reader.GetAttribute("location")); } else if (reader.Name.Equals("MainLocation")) { mainLocations.Add(reader.GetAttribute("key"), reader.GetAttribute("name")); } break; case XmlNodeType.Text: if (eventName != null) { RemnantItem rItem = new RemnantItem(reader.Value); if (itemMode != null) { if (itemMode.Equals("hardcore")) { rItem.ItemMode = RemnantItem.RemnantItemMode.Hardcore; } else if (itemMode.Equals("survival")) { rItem.ItemMode = RemnantItem.RemnantItemMode.Survival; } } if (itemNotes != null) { rItem.ItemNotes = itemNotes; } eventItems.Add(rItem); itemMode = null; itemNotes = null; } break; case XmlNodeType.EndElement: if (reader.Name.Equals("Event")) { eventItem.Add(eventName, eventItems.ToArray()); eventName = null; eventItems.Clear(); } break; } } reader.Close(); }