public void ProcessRequest(HttpContext context)
        {
            bool     value   = false;
            string   message = "获取失败!";
            XElement result  = new XElement("Result");

            try
            {
                using (MapBussiness db = new MapBussiness())
                {
                    //MapWeekInfo[] infos = db.GetAllMapWeek();
                    //foreach (MapWeekInfo info in infos)
                    //{
                    //    result.Add(FlashUtils.CreateMapWeek(info));
                    //}

                    value   = true;
                    message = "获取成功!";
                }
            }
            catch (Exception ex)
            {
                log.Error("加载地图周期失败", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));

            context.Response.ContentType = "text/plain";
            context.Response.Write(result.ToString(false));
        }
Esempio n. 2
0
        public static string Bulid(HttpContext context)
        {
            bool   value   = false;
            string message = "Fail";

            XElement result = new XElement("Result");

            try
            {
                using (MapBussiness db = new MapBussiness())
                {
                    ServerMapInfo[] infos = db.GetAllServerMap();
                    foreach (ServerMapInfo info in infos)
                    {
                        result.Add(FlashUtils.CreateMapServer(info));
                    }
                }

                value   = true;
                message = "Success!";
            }
            catch (Exception ex)
            {
                log.Error("MapServerList", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));
            //return result.ToString(false);
            return(csFunction.CreateCompressXml(context, result, "MapServerList", true));
        }
Esempio n. 3
0
        public static bool InitServerMap(Dictionary <int, List <int> > servermap)
        {
            ServerMapInfo[] infos;
            using (MapBussiness db = new MapBussiness())
            {
                infos = db.GetAllServerMap();
            }
            try
            {
                var temp = 0;
                foreach (ServerMapInfo info in infos)
                {
                    //if (info.WeekID < 1 || info.WeekID > 7)
                    //    continue;

                    if (!servermap.Keys.Contains(info.ServerID))
                    {
                        string[]   str  = info.OpenMap.Split(',');
                        List <int> list = new List <int>();
                        foreach (string s in str)
                        {
                            if (string.IsNullOrEmpty(s))
                            {
                                continue;
                            }
                            if (int.TryParse(s, out temp))
                            {
                                list.Add(temp);
                            }
                        }
                        servermap.Add(info.ServerID, list);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }

            return(true);
        }
Esempio n. 4
0
        public static string Bulid(HttpContext context)
        {
            bool   value   = false;
            string message = "Fail";

            XElement result = new XElement("Result");

            try
            {
                //TankDBDataContext db = new TankDBDataContext();
                //var query = from m in db.Game_Maps
                //            where m.PosX != null && m.PosX != ""
                //            select m;
                //foreach (var m in query)
                //{
                //    result.Add(Road.Flash.FlashUtils.CreateMapInfo(m));
                //}

                using (MapBussiness db = new MapBussiness())
                {
                    MapInfo[] infos = db.GetAllMap();
                    foreach (MapInfo info in infos)
                    {
                        result.Add(Road.Flash.FlashUtils.CreateMapInfo(info));
                    }
                }

                value   = true;
                message = "Success!";
            }
            catch (Exception ex)
            {
                log.Error("LoadMapsItems", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));
            return(csFunction.CreateCompressXml(context, result, "LoadMapsItems", true));
        }
Esempio n. 5
0
        public static bool InitServerMap(Dictionary <int, List <int> > servermap)
        {
            MapBussiness mapBussiness = new MapBussiness();

            ServerMapInfo[] allServerMap = mapBussiness.GetAllServerMap();
            try
            {
                int             item  = 0;
                ServerMapInfo[] array = allServerMap;
                for (int i = 0; i < array.Length; i++)
                {
                    ServerMapInfo serverMapInfo = array[i];
                    if (!servermap.Keys.Contains(serverMapInfo.ServerID))
                    {
                        string[] array2 = serverMapInfo.OpenMap.Split(new char[]
                        {
                            ','
                        });
                        List <int> list   = new List <int>();
                        string[]   array3 = array2;
                        for (int j = 0; j < array3.Length; j++)
                        {
                            string text = array3[j];
                            if (!string.IsNullOrEmpty(text) && int.TryParse(text, out item))
                            {
                                list.Add(item);
                            }
                        }
                        servermap.Add(serverMapInfo.ServerID, list);
                    }
                }
            }
            catch (Exception ex)
            {
                MapMgr.log.Error(ex.ToString());
            }
            return(true);
        }
Esempio n. 6
0
        public static bool LoadMap(Dictionary <int, MapPoint> maps, Dictionary <int, Map> mapInfos)
        {
            try
            {
                MapInfo[] query;
                using (MapBussiness db = new MapBussiness())
                {
                    query = db.GetAllMap();
                }

                foreach (MapInfo m in query)
                {
                    if (string.IsNullOrEmpty(m.PosX)) //|| string.IsNullOrEmpty(m.PosX1))
                    {
                        continue;
                    }

                    if (!maps.Keys.Contains(m.ID))
                    {
                        string[] tmp  = m.PosX.Split('|');
                        string[] tmp1 = m.PosX1.Split('|');
                        //List<Point> pos = new List<Point>();
                        MapPoint pos = new MapPoint();
                        foreach (string s in tmp)
                        {
                            if (string.IsNullOrEmpty(s.Trim()))
                            {
                                continue;
                            }

                            string[] xy = s.Split(',');
                            pos.PosX.Add(new Point(int.Parse(xy[0]), int.Parse(xy[1])));
                            //Point temp = new Point(int.Parse(xy[0]), int.Parse(xy[1]));
                            //pos.Add(temp);
                        }

                        foreach (string s in tmp1)
                        {
                            if (string.IsNullOrEmpty(s.Trim()))
                            {
                                continue;
                            }

                            string[] xy = s.Split(',');
                            pos.PosX1.Add(new Point(int.Parse(xy[0]), int.Parse(xy[1])));
                            //Point temp = new Point(int.Parse(xy[0]), int.Parse(xy[1]));
                            //pos.Add(temp);
                        }

                        maps.Add(m.ID, pos);
                    }

                    if (!mapInfos.ContainsKey(m.ID))
                    {
                        Tile   force = null;
                        string file  = string.Format("map\\{0}\\fore.map", m.ID);
                        if (File.Exists(file))
                        {
                            force = new Tile(file, true);
                        }

                        Tile dead = null;
                        file = string.Format("map\\{0}\\dead.map", m.ID);
                        if (File.Exists(file))
                        {
                            dead = new Tile(file, false);
                        }

                        if (force != null || dead != null)
                        {
                            mapInfos.Add(m.ID, new Map(m, force, dead));
                        }
                        else
                        {
                            if (log.IsErrorEnabled)
                            {
                                log.Error("Map's file is not exist!");
                            }
                            return(false);
                        }
                    }
                }

                if (maps.Count == 0 || mapInfos.Count == 0)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("maps:" + maps.Count + ",mapInfos:" + mapInfos.Count);
                    }
                    return(false);
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("MapMgr", e);
                }
                return(false);
            }
            return(true);
        }
Esempio n. 7
0
 public static bool LoadMap(Dictionary <int, MapPoint> maps, Dictionary <int, Map> mapInfos)
 {
     try
     {
         MapBussiness mapBussiness = new MapBussiness();
         MapInfo[]    allMap       = mapBussiness.GetAllMap();
         MapInfo[]    array        = allMap;
         for (int i = 0; i < array.Length; i++)
         {
             MapInfo mapInfo = array[i];
             if (!string.IsNullOrEmpty(mapInfo.PosX))
             {
                 if (!maps.Keys.Contains(mapInfo.ID))
                 {
                     string[] array2 = mapInfo.PosX.Split(new char[]
                     {
                         '|'
                     });
                     string[] array3 = mapInfo.PosX1.Split(new char[]
                     {
                         '|'
                     });
                     MapPoint mapPoint = new MapPoint();
                     string[] array4   = array2;
                     for (int j = 0; j < array4.Length; j++)
                     {
                         string text = array4[j];
                         if (!string.IsNullOrEmpty(text.Trim()))
                         {
                             string[] array5 = text.Split(new char[]
                             {
                                 ','
                             });
                             mapPoint.PosX.Add(new Point(int.Parse(array5[0]), int.Parse(array5[1])));
                         }
                     }
                     string[] array6 = array3;
                     for (int k = 0; k < array6.Length; k++)
                     {
                         string text2 = array6[k];
                         if (!string.IsNullOrEmpty(text2.Trim()))
                         {
                             string[] array7 = text2.Split(new char[]
                             {
                                 ','
                             });
                             mapPoint.PosX1.Add(new Point(int.Parse(array7[0]), int.Parse(array7[1])));
                         }
                     }
                     maps.Add(mapInfo.ID, mapPoint);
                 }
                 if (!mapInfos.ContainsKey(mapInfo.ID))
                 {
                     Tile   tile  = null;
                     string text3 = string.Format("map\\{0}\\fore.map", mapInfo.ID);
                     if (File.Exists(text3))
                     {
                         tile = new Tile(text3, true);
                     }
                     Tile tile2 = null;
                     text3 = string.Format("map\\{0}\\dead.map", mapInfo.ID);
                     if (File.Exists(text3))
                     {
                         tile2 = new Tile(text3, false);
                     }
                     if (tile == null && tile2 == null)
                     {
                         if (MapMgr.log.IsErrorEnabled)
                         {
                             MapMgr.log.Error("Map's file is not exist!");
                         }
                         bool result = false;
                         return(result);
                     }
                     mapInfos.Add(mapInfo.ID, new Map(mapInfo, tile, tile2));
                 }
             }
         }
         if (maps.Count == 0 || mapInfos.Count == 0)
         {
             if (MapMgr.log.IsErrorEnabled)
             {
                 MapMgr.log.Error(string.Concat(new object[]
                 {
                     "maps:",
                     maps.Count,
                     ",mapInfos:",
                     mapInfos.Count
                 }));
             }
             bool result = false;
             return(result);
         }
     }
     catch (Exception exception)
     {
         if (MapMgr.log.IsErrorEnabled)
         {
             MapMgr.log.Error("MapMgr", exception);
         }
         bool result = false;
         return(result);
     }
     return(true);
 }
Esempio n. 8
0
        public static bool InitServerMap(Dictionary <int, List <int> > _serverMap, Dictionary <int, List <int> > simpleMapList, Dictionary <int, List <int> > normalMapList, Dictionary <int, List <int> > difficultMapList, Dictionary <int, List <int> > professionalMapList)
        {
            bool result;

            using (MapBussiness db = new MapBussiness())
            {
                ServerMapInfo[] serverMapList = db.GetAllServerMap();
                try
                {
                    ServerMapInfo[] array = serverMapList;
                    for (int i = 0; i < array.Length; i++)
                    {
                        ServerMapInfo serverMap = array[i];
                        if (!_serverMap.Keys.Contains(serverMap.ServerID))
                        {
                            string[] mapStr = serverMap.OpenMap.Split(new char[]
                            {
                                '|'
                            });
                            if (mapStr.Length < 4)
                            {
                                MapMgr.log.Error(serverMap.ServerID + " 号服务器新手地图加载失败,数据格式错误!");
                            }
                            else
                            {
                                string[] simpleMap = mapStr[0].Split(new char[]
                                {
                                    ','
                                });
                                string[] normalMap = mapStr[1].Split(new char[]
                                {
                                    ','
                                });
                                string[] difficultMap = mapStr[2].Split(new char[]
                                {
                                    ','
                                });
                                string[] professionalMap = mapStr[3].Split(new char[]
                                {
                                    ','
                                });
                                List <int> smaps   = new List <int>();
                                List <int> nmaps   = new List <int>();
                                List <int> dmaps   = new List <int>();
                                List <int> pmaps   = new List <int>();
                                List <int> allmaps = new List <int>();
                                string[]   array2  = simpleMap;
                                for (int j = 0; j < array2.Length; j++)
                                {
                                    string map = array2[j];
                                    if (!string.IsNullOrEmpty(map))
                                    {
                                        int mapId = int.Parse(map);
                                        allmaps.Add(mapId);
                                        smaps.Add(mapId);
                                    }
                                }
                                simpleMapList.Add(serverMap.ServerID, smaps);
                                array2 = normalMap;
                                for (int j = 0; j < array2.Length; j++)
                                {
                                    string map = array2[j];
                                    if (!string.IsNullOrEmpty(map))
                                    {
                                        int mapId = int.Parse(map);
                                        allmaps.Add(mapId);
                                        nmaps.Add(mapId);
                                    }
                                }
                                normalMapList.Add(serverMap.ServerID, nmaps);
                                array2 = difficultMap;
                                for (int j = 0; j < array2.Length; j++)
                                {
                                    string map = array2[j];
                                    if (!string.IsNullOrEmpty(map))
                                    {
                                        int mapId = int.Parse(map);
                                        allmaps.Add(mapId);
                                        dmaps.Add(mapId);
                                    }
                                }
                                difficultMapList.Add(serverMap.ServerID, dmaps);
                                array2 = professionalMap;
                                for (int j = 0; j < array2.Length; j++)
                                {
                                    string map = array2[j];
                                    if (!string.IsNullOrEmpty(map))
                                    {
                                        int mapId = int.Parse(map);
                                        allmaps.Add(mapId);
                                        pmaps.Add(mapId);
                                    }
                                }
                                professionalMapList.Add(serverMap.ServerID, pmaps);
                                _serverMap.Add(serverMap.ServerID, allmaps);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MapMgr.log.Error(ex.ToString());
                    result = false;
                    return(result);
                }
            }
            result = true;
            return(result);
        }
Esempio n. 9
0
        public static bool LoadMap(Dictionary <int, MapPoint> maps, Dictionary <int, Map> mapInfos)
        {
            bool result;

            try
            {
                using (MapBussiness db = new MapBussiness())
                {
                    MapInfo[] query = db.GetAllMap();
                    MapInfo[] array = query;
                    for (int j = 0; j < array.Length; j++)
                    {
                        MapInfo i = array[j];
                        if (!string.IsNullOrEmpty(i.PosX))
                        {
                            MapMgr._mapInstancePool.Add(i.ID, new Queue <Map>());
                            if (!maps.Keys.Contains(i.ID))
                            {
                                string[] tmp = i.PosX.Split(new char[]
                                {
                                    '|'
                                });
                                string[] tmp2 = i.PosX1.Split(new char[]
                                {
                                    '|'
                                });
                                string[] tmp3 = i.PosX2.Split(new char[]
                                {
                                    '|'
                                });
                                MapPoint pos    = new MapPoint();
                                string[] array2 = tmp;
                                for (int k = 0; k < array2.Length; k++)
                                {
                                    string s = array2[k];
                                    if (!string.IsNullOrEmpty(s.Trim()))
                                    {
                                        string[] xy = s.Split(new char[]
                                        {
                                            ','
                                        });
                                        pos.PosX.Add(new Point(int.Parse(xy[0]), int.Parse(xy[1])));
                                    }
                                }
                                array2 = tmp2;
                                for (int k = 0; k < array2.Length; k++)
                                {
                                    string s = array2[k];
                                    if (!string.IsNullOrEmpty(s.Trim()))
                                    {
                                        string[] xy = s.Split(new char[]
                                        {
                                            ','
                                        });
                                        pos.PosX1.Add(new Point(int.Parse(xy[0]), int.Parse(xy[1])));
                                    }
                                }
                                array2 = tmp3;
                                for (int k = 0; k < array2.Length; k++)
                                {
                                    string s = array2[k];
                                    if (!string.IsNullOrEmpty(s.Trim()))
                                    {
                                        string[] xy = s.Split(new char[]
                                        {
                                            ','
                                        });
                                        pos.PosX2.Add(new Point(int.Parse(xy[0]), int.Parse(xy[1])));
                                    }
                                }
                                maps.Add(i.ID, pos);
                            }
                            if (!mapInfos.ContainsKey(i.ID))
                            {
                                Tile   force = null;
                                string file  = string.Format("map\\{0}\\fore.map", i.ID);
                                if (File.Exists(file))
                                {
                                    force = new Tile(file, true);
                                }
                                Tile dead = null;
                                file = string.Format("map\\{0}\\dead.map", i.ID);
                                if (File.Exists(file))
                                {
                                    dead = new Tile(file, false);
                                }
                                if (force == null && dead == null)
                                {
                                    //if (MapMgr.log.IsErrorEnabled)
                                    {
                                        MapMgr.log.Error("地图" + i.ID.ToString() + "不存在!");
                                    }
                                    result = false;
                                    return(result);
                                }
                                mapInfos.Add(i.ID, new Map(i, force, dead));
                            }
                        }
                    }
                    if (maps.Count == 0 || mapInfos.Count == 0)
                    {
                        //if (MapMgr.log.IsErrorEnabled)
                        {
                            MapMgr.log.Error(string.Concat(new object[]
                            {
                                "maps:",
                                maps.Count,
                                ",mapInfos:",
                                mapInfos.Count
                            }));
                        }
                        result = false;
                        return(result);
                    }
                }
            }
            catch (Exception e)
            {
                //if (MapMgr.log.IsErrorEnabled)
                {
                    MapMgr.log.Error("MapMgr", e);
                }
                result = false;
                return(result);
            }
            result = true;
            return(result);
        }