示例#1
0
        public bool Save(MapConfig mc)
        {
            bool ret = false;

            if (mapDictionary.ContainsKey(mc.name))
            {
                mc.Save();
                ret = true;
            }
            else
            {
                mapDictionary.Add(mc.name, mc);


                MapListConfig ver = new MapListConfig();
                ver.mapID   = mc.name;
                ver.version = 0;
                ver.nAdd    = 0;
                mapVersion.Add(ver.mapID, ver);
                mc.Save();
                ret = true;
            }
            WriteMapList();
            return(ret);
        }
示例#2
0
        public MapListConfig GetMapVersion(string Id)
        {
            MapListConfig cfg = null;

            if (mapVersion.ContainsKey(Id))
            {
                return(mapVersion[Id]);
            }
            return(cfg);
        }
示例#3
0
        /// <summary>
        /// 修改地图的版本
        /// </summary>
        public bool ModifymapVersion(string mapId)
        {
            MapListConfig cfg = GetMapVersion(mapId);

            if (cfg != null)
            {
                cfg.nAdd += 1;
                return(true);
            }

            return(true);
        }
示例#4
0
        public bool SyncmapVersion(string mapId)
        {
            MapListConfig cfg = GetMapVersion(mapId);

            if (cfg != null)
            {
                cfg.version += cfg.nAdd;
                cfg.nAdd     = 0;
                return(true);
            }

            return(false);
        }
示例#5
0
        public void Load()
        {
            mapVersion.Clear();
            mapDictionary.Clear();
            try
            {
                string url = UtilTools.GetStreamAssetsByPlatform(Path());
                if (string.IsNullOrEmpty(url))
                {
                    return;
                }

                /// 试着用www 读取
                WWW www = new WWW(url);
                while (!www.isDone)
                {
                    ;
                }

                if (!string.IsNullOrEmpty(www.text))
                {
                    XDocument xmlDoc   = XDocument.Parse(www.text);
                    var       xElement = xmlDoc.Element("maps");
                    if (xElement == null)
                    {
                        return;
                    }

                    var elements = xElement.Elements("map");
                    foreach (var em in elements)
                    {
                        MapListConfig item = new MapListConfig();
                        if (item.Load(em))
                        {
                            MapConfig tmc = new MapConfig(item.mapID);
                            tmc.Load();
                            mapDictionary.Add(item.mapID, tmc);
                            mapVersion.Add(item.mapID, item);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LoggerSystem.Instance.Error("maplist resource failed " + e.ToString());
            }

            LoadExtraData();
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }