Example #1
0
        /// <summary>
        /// 为一个地图, logical文件建立索引 和 获取区域信息
        /// </summary>
        /// <param name="mapname"></param>
        /// <returns></returns>
        private bool InithtNpcIndexAndRegionInfo4OneMap(string mapname)
        {
            NpcIndex   npcindex   = null;
            RegionInfo regionInfo = null;

            if (!htNpcIndex.ContainsKey(mapname))
            {
                npcindex         = new NpcIndex(strRootDir);
                npcindex.MapName = mapname;
                if (npcindex.Init())
                {
                    htNpcIndex[mapname] = npcindex;
                }
                else
                {
                    sbErrorMsg.Append(npcindex.ErrorMsg);
                }
            }
            if (!htRegionInfo.ContainsKey(mapname))
            {
                regionInfo = new RegionInfo();
                if (regionInfo.Init(strRootDir, mapname))
                {
                    htRegionInfo[mapname] = regionInfo;
                }
                else
                {
                    sbErrorMsg.Append(regionInfo.strErrorMsg);
                }
            }
            return(true);
        }
Example #2
0
        /// <summary>
        /// 为一个地图, logical文件建立索引 和 获取区域信息
        /// </summary>
        /// <param name="mapname"></param>
        /// <returns></returns>
         private bool InithtNpcIndexAndRegionInfo4OneMap(string mapname)
         {
             NpcIndex npcindex = null;
             RegionInfo regionInfo = null;

             if (!htNpcIndex.ContainsKey(mapname))
             {
                 npcindex = new NpcIndex(strRootDir);
                 npcindex.MapName = mapname;
                 if (npcindex.Init())
                 {
                     htNpcIndex[mapname] = npcindex;
                 }
                 else
                 {
                     sbErrorMsg.Append(npcindex.ErrorMsg);
                 }
             }
             if (!htRegionInfo.ContainsKey(mapname))
             {
                 regionInfo = new RegionInfo();
                 if (regionInfo.Init(strRootDir, mapname))
                 {
                     htRegionInfo[mapname] = regionInfo;
                 }
                 else
                 {
                     sbErrorMsg.Append(regionInfo.strErrorMsg);
                 }
             }
             return true;

         }
Example #3
0
        /// <summary>
        /// 更新dt所含有的行
        /// </summary>
        /// <param name="dt"></param>
        private void Update4Table(DataTable dt)
        {
            string     mapname     = string.Empty;
            int        templateid  = 0;
            int        middlemapid = 0;
            PointXY    point;
            NpcIndex   npcindex   = null;
            RegionInfo regionInfo = null;
            string     sqlupdate  = string.Empty;

            foreach (DataRow dr in dt.Rows)
            {
                mapname    = dr["map"].ToString();
                templateid = Convert.ToInt32(dr["id"]);

                if (templateid == 0)
                {
                    continue;
                }

                npcindex   = htNpcIndex[mapname] as NpcIndex;
                regionInfo = htRegionInfo[mapname] as RegionInfo;

                if (npcindex != null)
                {
                    point = npcindex.GetPoint(templateid);

                    if (point.nX == 0 && point.nY == 0)
                    {
                        string str = string.Format("场景文件.Map.Logical中找不到此npc,建议删除之。\r\n场景名:{0}  \r\nnpc模板id:{1}", mapname, templateid);
                        //MessageBox.Show(str);
                        Console.WriteLine(str);
                        continue;
                    }

                    if (regionInfo != null)
                    {
                        middlemapid = regionInfo.GetMiddleMapId(point.nX, point.nY);
                    }

                    sqlupdate = string.Format("update {0} set x = {1}, y = {2}, middlemap = {3} where id = {4}", TableName, point.nX, point.nY, middlemapid, templateid);//middlemap的更新暂时没加
                    Helper.ExecuteSqlCmd(sqlupdate, Conn);
                }
            }
        }