//根据nTempleteID获得坐标 //id不存在返回0,0 public PointXY GetPoint(int templateid) { PointXY pointRet; if (!htIndex.ContainsKey(templateid)) { strErrorMsg = string.Format("mapname = {0},nTempleteID = {1} is not exists.\r\n", strMapName, templateid); pointRet = new PointXY(); pointRet.nX = 0; pointRet.nY = 0; } else { pointRet = (PointXY)htIndex[templateid]; } return(pointRet); }
//读取strMapName的Logical.map文件,填充htIndex private bool ReadLogicalFile() { string strMapLogicalFileFullName = string.Format("{0}\\data\\source\\maps\\{1}\\{1}.Map.Logical", strRootDir, strMapName); if (!File.Exists(strMapLogicalFileFullName)) { strErrorMsg = string.Format("file {0} is not exists!\r\n", strMapLogicalFileFullName); return(false); } // 读文件 string content = Helper.FileToString(strMapLogicalFileFullName, Encoding.Default); byte[] bytes = Encoding.Default.GetBytes(content); bytes = Encoding.Convert(Encoding.Default, Encoding.Unicode, bytes); char[] chars = Encoding.Unicode.GetChars(bytes); content = new String(chars); Helper.OpenIniFile(strMapLogicalFileFullName, content); if (Helper.m_inis == null) { strErrorMsg = string.Format("{0} 不是正确的ini格式,\r\n可能包含有 \"<<<<<<< .mine\" 等 SVN 合并残留字符串。\r\n请检查之。", strMapLogicalFileFullName); return(false); } int NpcCnt = Convert.ToInt32(Helper.GetIniString("MAIN", "NumNPC")); string strSection = string.Empty; int nTempleteID = 0; for (int i = 0; i < NpcCnt; ++i) { strSection = string.Format("NPC{0}", i); nTempleteID = Convert.ToInt32(Helper.GetIniString(strSection, "nTempleteID")); if (!htIndex.ContainsKey(nTempleteID)) { PointXY point = new PointXY(); point.nX = Convert.ToInt32(Helper.GetIniString(strSection, "nX")); point.nY = Convert.ToInt32(Helper.GetIniString(strSection, "nY")); htIndex[nTempleteID] = point; } } Helper.CloseIniFile(); return(true); }
//读取strMapName的Logical.map文件,填充htIndex private bool ReadLogicalFile() { string strMapLogicalFileFullName = string.Format("{0}\\data\\source\\maps\\{1}\\{1}.Map.Logical", strRootDir, strMapName); if (!File.Exists(strMapLogicalFileFullName)) { strErrorMsg = string.Format("file {0} is not exists!\r\n", strMapLogicalFileFullName); return false; } // 读文件 string content = Helper.FileToString(strMapLogicalFileFullName, Encoding.Default); byte[] bytes = Encoding.Default.GetBytes(content); bytes = Encoding.Convert(Encoding.Default, Encoding.Unicode, bytes); char[] chars = Encoding.Unicode.GetChars(bytes); content = new String(chars); Helper.OpenIniFile(strMapLogicalFileFullName, content); if (Helper.m_inis == null) { strErrorMsg = string.Format("{0} 不是正确的ini格式,\r\n可能包含有 \"<<<<<<< .mine\" 等 SVN 合并残留字符串。\r\n请检查之。", strMapLogicalFileFullName); return false; } int NpcCnt = Convert.ToInt32(Helper.GetIniString("MAIN", "NumNPC")); string strSection = string.Empty; int nTempleteID = 0; for (int i = 0; i < NpcCnt; ++i) { strSection = string.Format("NPC{0}", i); nTempleteID = Convert.ToInt32(Helper.GetIniString(strSection, "nTempleteID")); if (!htIndex.ContainsKey(nTempleteID)) { PointXY point = new PointXY(); point.nX = Convert.ToInt32(Helper.GetIniString(strSection, "nX")); point.nY = Convert.ToInt32(Helper.GetIniString(strSection, "nY")); htIndex[nTempleteID] = point; } } Helper.CloseIniFile(); return true; }
//根据nTempleteID获得坐标 //id不存在返回0,0 public PointXY GetPoint(int templateid) { PointXY pointRet; if (!htIndex.ContainsKey(templateid)) { strErrorMsg = string.Format("mapname = {0},nTempleteID = {1} is not exists.\r\n", strMapName, templateid); pointRet = new PointXY(); pointRet.nX = 0; pointRet.nY = 0; } else { pointRet = (PointXY)htIndex[templateid]; } return pointRet; }