public bool Init(string strRootdir, Hashtable htMapId) { m_strRootDir = strRootdir; string strMapName; int nMapId; foreach (DictionaryEntry de in htMapId) { strMapName = de.Value.ToString(); nMapId = (int)de.Key; m_htMapId[strMapName] = nMapId; m_htMapName[nMapId] = strMapName; } string strLogicalFilePath; const string NPC = "NPC"; const string Doodad = "Doodad"; string[] ReadingColumns = { nXColumnName, nYColumnName, nTempleteIDColumnName }; foreach (string mapname in m_htMapName.Values) { strLogicalFilePath = string.Format("{0}/data/source/maps/{1}/{1}.Map.Logical", m_strRootDir, mapname); MapLogicalTableReader npcReader = new MapLogicalTableReader(strLogicalFilePath, NPC, ReadingColumns); MapLogicalTableReader DoodadReader = new MapLogicalTableReader(strLogicalFilePath, Doodad, ReadingColumns); if (npcReader.Init()) { m_htMapNameNpcTable[mapname] = npcReader; } if (DoodadReader.Init()) { m_htMapNameDoodadTable[mapname] = DoodadReader; } //regionInfo //RegionInfo region = new RegionInfo(); //if (region.Init(m_strRootDir, mapname)) //{ // m_htRegionInfo[mapname] = region; //} // //Hashtable htTemplateIdGreeyIds = new Hashtable(MaxTemplateCapcity); //m_htMapNameHashTableGreeyIds[mapname] = htTemplateIdGreeyIds; } return(true); }
/// <summary> /// 根据nTemplateId 和type更新当前地图名称 /// 如果所有的地图都找不到返回false /// </summary> /// <param name="nTemplateId"></param> /// <param name="rows">返回该nTemplateId对应的行</param> /// <param name="type"></param> /// <returns></returns> private bool UpdateCurrentMapName(int nTemplateId, TemplateType ttype, QuestColumnType colType, ref DataRow[] rows, ref string newMapName) { Hashtable htMapNameReader = null; switch (ttype) { case TemplateType.NPC_TEMPLATE: htMapNameReader = m_htMapNameNpcTable; break; case TemplateType.DOODAD_TEMPLATE: htMapNameReader = m_htMapNameDoodadTable; break; default: return(false); } if (htMapNameReader.ContainsKey(m_strCurrentMapName)) { MapLogicalTableReader reader = htMapNameReader[m_strCurrentMapName] as MapLogicalTableReader; rows = reader.Select(nTempleteIDColumnName, nTemplateId.ToString()); if (rows.Length > 0) { return(true); } } if (colType == QuestColumnType.START && m_htMapName.ContainsKey(m_nCurrentStartMapId)) { string mapname = m_htMapName[m_nCurrentStartMapId] as string; MapLogicalTableReader reader = htMapNameReader[mapname] as MapLogicalTableReader; if (reader != null) { rows = reader.Select(nTempleteIDColumnName, nTemplateId.ToString()); if (rows.Length > 0) { newMapName = mapname; return(true); } } } else if (colType == QuestColumnType.END && m_htMapName.ContainsKey(m_nCurrentEndMapId)) { string mapname = m_htMapName[m_nCurrentEndMapId] as string; MapLogicalTableReader reader = htMapNameReader[mapname] as MapLogicalTableReader; if (reader != null) { rows = reader.Select(nTempleteIDColumnName, nTemplateId.ToString()); if (rows.Length > 0) { newMapName = mapname; return(true); } } } foreach (DictionaryEntry de in htMapNameReader) { MapLogicalTableReader reader = de.Value as MapLogicalTableReader; string mapname = de.Key as string; rows = reader.Select(nTempleteIDColumnName, nTemplateId.ToString()); if (rows.Length > 0) { newMapName = mapname; return(true); } } return(false); }