public void AddMapBot(MapBot mapBot) { MapBots.Add(mapBot); var sb = new StringBuilder(); _minBotsLevel = 0; _maxBotsLevel = 0; foreach (var bot in MapBots) { if (sb.Length > 0) { sb.AppendLine(); _minBotsLevel = Math.Min(_minBotsLevel, bot.MinLevel); _maxBotsLevel = Math.Max(_maxBotsLevel, bot.MaxLevel); } else { _minBotsLevel = bot.MinLevel; _maxBotsLevel = bot.MaxLevel; } sb.AppendFormat("{0} {1}-{2}", bot.Name, bot.MinLevel, bot.MaxLevel); } _botsTooltip = sb.ToString(); }
private static void LoadMap() { var pathCellsXml = Path.Combine(Application.StartupPath, "map.xml"); if (!File.Exists(pathCellsXml)) { return; } var xml = new XmlDocument(); xml.LoadXml(File.ReadAllText(pathCellsXml)); var ecells = xml.GetElementsByTagName(AppConsts.TagMapCell); foreach (XmlNode ecell in ecells) { if (ecell.Attributes == null) { continue; } var cell = new Cell(); cell.CellNumber = ecell.Attributes[AppConsts.AttrMapCellNumber].Value.Trim(); int cost; int.TryParse(ecell.Attributes[AppConsts.AttrMapCellCost].Value.Trim(), out cost); cell.Cost = cost; bool hasFish; bool.TryParse(ecell.Attributes[AppConsts.AttrMapCellHasFish].Value.Trim(), out hasFish); cell.HasFish = hasFish; bool hasWater; bool.TryParse(ecell.Attributes[AppConsts.AttrMapCellHasWater].Value.Trim(), out hasWater); cell.HasWater = hasWater; cell.HerbGroup = ecell.Attributes[AppConsts.AttrMapCellHerbGroup].Value.Trim(); cell.Name = ecell.Attributes[AppConsts.AttrMapCellName].Value.Trim(); cell.Tooltip = ecell.Attributes[AppConsts.AttrMapCellTooltip].Value.Trim(); cell.Updated = ecell.Attributes[AppConsts.AttrMapCellUpdated].Value.Trim(); cell.NameUpdated = ecell.Attributes[AppConsts.AttrMapCellNameUpdated].Value.Trim(); cell.CostUpdated = ecell.Attributes[AppConsts.AttrMapCellCostUpdated].Value.Trim(); Cells.Add(cell.CellNumber, cell); } var ebots = xml.GetElementsByTagName(AppConsts.TagMapBots); foreach (XmlNode ebot in ebots) { if (ebot.Attributes == null) { continue; } var name = ebot.Attributes[AppConsts.AttrMapBotsName].Value.Trim(); int minLevel; int.TryParse(ebot.Attributes[AppConsts.AttrMapBotsMinLevel].Value, out minLevel); int maxLevel; int.TryParse(ebot.Attributes[AppConsts.AttrMapBotsMaxLevel].Value, out maxLevel); var c = ebot.Attributes[AppConsts.AttrMapBotsC].Value; var d = ebot.Attributes[AppConsts.AttrMapBotsD].Value; var mapbot = new MapBot(name, minLevel, maxLevel, c, d); var ecell = ebot.ParentNode; if (ecell != null) { var cellNumber = Cell.NormalizeRegNum(ecell.Attributes[AppConsts.AttrMapCellNumber].Value.Trim()); if (Cells.ContainsKey(cellNumber)) { Cells[cellNumber].AddMapBot(mapbot); } else { throw new Exception(cellNumber); } } } }