public PlayerResearch(PlayerBuilding pb, Research r) { Building = pb; Research = r; }
public TypeConstruction(XmlNode n) : base(n) { Page = (Page)Enum.Parse(typeof(Page), n.SelectSingleNode("Page").InnerText); Line = XmlUtils.GetInteger(n.SelectSingleNode("Line")); Pos = XmlUtils.GetInteger(n.SelectSingleNode("Pos")); HasTreasury = XmlUtils.GetBool(n.SelectSingleNode("HasTreasury"), false); GoldByConstruction = XmlUtils.GetInteger(n.SelectSingleNode("GoldByConstruction")); DefaultLevel = XmlUtils.GetInteger(n.SelectSingleNode("DefaultLevel")); MaxLevel = XmlUtils.GetInteger(n.SelectSingleNode("MaxLevel")); LevelAsQuantity = XmlUtils.GetBool(n.SelectSingleNode("LevelAsQuantity"), false); PointConstructionGuild = XmlUtils.GetInteger(n.SelectSingleNode("PointConstructionGuild")); PointConstructionEconomic = XmlUtils.GetInteger(n.SelectSingleNode("PointConstructionEconomic")); PointConstructionTemple = XmlUtils.GetInteger(n.SelectSingleNode("PointConstructionTemple")); PointConstructionTradePost = XmlUtils.GetInteger(n.SelectSingleNode("PointConstructionTradePost")); Debug.Assert(DefaultLevel >= 0); Debug.Assert(DefaultLevel <= 5); Debug.Assert(MaxLevel > 0); Debug.Assert(MaxLevel <= 10); Debug.Assert(DefaultLevel <= MaxLevel); Debug.Assert(PointConstructionGuild >= 0); Debug.Assert(PointConstructionGuild <= 1); Debug.Assert(PointConstructionEconomic >= 0); Debug.Assert(PointConstructionEconomic <= 1); Debug.Assert(PointConstructionTemple >= 0); Debug.Assert(PointConstructionTemple <= 1); Debug.Assert(PointConstructionTradePost >= 0); Debug.Assert(PointConstructionTradePost <= 1); // Загружаем информацию об уровнях Levels = new Level[MaxLevel + 1];// Для упрощения работы с уровнями, добавляем 1, чтобы уровень был равен индексу в массиве XmlNode nl = n.SelectSingleNode("Levels"); if (nl != null) { Level level; foreach (XmlNode l in nl.SelectNodes("Level")) { level = new Level(l); Debug.Assert(Levels[level.Pos] == null); /*switch (TypeIncome) * { * case TypeIncome.None: * Debug.Assert(level.Income == 0); * break; * case TypeIncome.PerHeroes: * break; * case TypeIncome.Persistent: * Debug.Assert(level.Income > 0); * break; * default: * throw new Exception("Неизвестный тип дохода."); * }*/ Levels[level.Pos] = level; } for (int i = 1; i < Levels.Length; i++) { if (Levels[i] == null) { throw new Exception("В конфигурации зданий у " + ID + " нет информации об уровне " + i.ToString()); } } } else { throw new Exception("В конфигурации зданий у " + ID + " нет информации об уровнях. "); } // Загружаем исследования XmlNode nr = n.SelectSingleNode("Researches"); if (nr != null) { Researches = new Research[Convert.ToInt32(n.SelectSingleNode("LayersResearches").InnerText), FormMain.Config.PlateHeight, FormMain.Config.PlateWidth]; Research research; foreach (XmlNode l in nr.SelectNodes("Research")) { research = new Research(l); Debug.Assert(Researches[research.Layer, research.Coord.Y, research.Coord.X] == null); Researches[research.Layer, research.Coord.Y, research.Coord.X] = research; } } }