public Stack <string> DownLoadMapList(string filePath) { try { Stack <string> list = new Stack <string>(); StreamReader file = File.OpenText(filePath); string text = file.ReadToEnd(); if (!string.IsNullOrEmpty(text)) { XDocument xmlDoc = XDocument.Parse(text); var xElement = xmlDoc.Element("maps"); if (xElement == null) { return(null); } var elements = xElement.Elements("map"); foreach (var em in elements) { MapListConfig item1 = new MapListConfig(); if (item1.Load(em)) { MapListConfig item2 = null; mapVersion.TryGetValue(item1.mapID, out item2); if (item2 == null) { list.Push(item1.mapID); } else if (item1.version > item2.version) { list.Push(item1.mapID); } } } } file.Close(); return(list); } catch (Exception e) { LoggerSystem.Instance.Error("maplist resource failed " + e.ToString()); } return(null); }
public Dictionary <string, MapListConfig> LoadExtraMapList() { Dictionary <string, MapListConfig> temp = new Dictionary <string, MapListConfig>(); try { string filePath = string.Empty; if (Application.platform == RuntimePlatform.WindowsEditor) { filePath = Application.dataPath + "/cache/EditMap/MapList.xml"; } else if (Application.platform == RuntimePlatform.Android) { filePath = Application.persistentDataPath + "/EditMap/MapList.xml"; } else if (Application.platform == RuntimePlatform.IPhonePlayer) { filePath = "file://" + Application.persistentDataPath + "/EditMap/MapList.xml"; } else if (Application.platform == RuntimePlatform.WindowsPlayer) { filePath = Application.dataPath + "/cache/EditMap/MapList.xml"; } StreamReader file = File.OpenText(filePath); string text = file.ReadToEnd(); if (!string.IsNullOrEmpty(text)) { XDocument xmlDoc = XDocument.Parse(text); var xElement = xmlDoc.Element("maps"); if (xElement == null) { return(null); } var elements = xElement.Elements("map"); foreach (var em in elements) { MapListConfig item = new MapListConfig(); if (item.Load(em)) { MapListConfig item1 = null; mapVersion.TryGetValue(item.mapID, out item1); if (item1 != null) { if (item.version > item1.version) { item1.version = item.version; temp.Add(item.mapID, item); } } else { mapVersion.Add(item.mapID, item); temp.Add(item.mapID, item); } } } } file.Close(); } catch (Exception e) { LoggerSystem.Instance.Error("maplist resource failed " + e.ToString()); } return(temp); }