public static GlobalColors Read(XmlDocument xml) { var globalColors = new GlobalColors(); var globalNodes = xml.GetElementsByTagName("global"); for (int i = 0; i < globalNodes.Count; i++) { string id = globalNodes[i].Attributes["id"].Value; string color = globalNodes[i].Attributes["color"].Value; switch (id) { case "sky": globalColors.SkyColor = (Color)ColorConverter.ConvertFromString(color); break; case "earth": globalColors.EarthColor = (Color)ColorConverter.ConvertFromString(color); break; case "rock": globalColors.RockColor = (Color)ColorConverter.ConvertFromString(color); break; case "hell": globalColors.HellColor = (Color)ColorConverter.ConvertFromString(color); break; case "water": globalColors.WaterColor = (Color)ColorConverter.ConvertFromString(color); break; case "lava": globalColors.LavaColor = (Color)ColorConverter.ConvertFromString(color); break; case "honey": globalColors.HoneyColor = (Color)ColorConverter.ConvertFromString(color); break; } } return(globalColors); }
public static StaticData Read(string filename) { var staticData = new StaticData(); var xmlDocument = new XmlDocument(); using (var stream = File.OpenRead(filename)) { xmlDocument.Load(stream); } staticData.TileInfos = TileInfos.Read(xmlDocument); staticData.WallInfos = WallInfo.Read(xmlDocument); staticData.GlobalColors = GlobalColors.Read(xmlDocument); staticData.ItemPrefixes = ItemPrefix.Read(xmlDocument); staticData.ItemInfos = ItemInfo.Read(xmlDocument); staticData.NpcInfoList = NpcInfo.Read(xmlDocument); return(staticData); }