public bool LoadCsv(string strContent) { if (strContent.Length == 0) { return(false); } m_mapElements.Clear(); m_vecAllElements.Clear(); int contentOffset = 0; List <string> vecLine; vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if (vecLine.Count != 10) { Ex.Logger.Log("CreatureSpawn.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "spawn_id") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_id]位置不对应"); return(false); } if (vecLine[1] != "npc_entry_id") { Ex.Logger.Log("CreatureSpawn.csv中字段[npc_entry_id]位置不对应"); return(false); } if (vecLine[2] != "spawn_map_id") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_map_id]位置不对应"); return(false); } if (vecLine[3] != "spawn_x") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_x]位置不对应"); return(false); } if (vecLine[4] != "spawn_y") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_y]位置不对应"); return(false); } if (vecLine[5] != "spawn_z") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_z]位置不对应"); return(false); } if (vecLine[6] != "refresh_time") { Ex.Logger.Log("CreatureSpawn.csv中字段[refresh_time]位置不对应"); return(false); } if (vecLine[7] != "refresh_type") { Ex.Logger.Log("CreatureSpawn.csv中字段[refresh_type]位置不对应"); return(false); } if (vecLine[8] != "animation_default") { Ex.Logger.Log("CreatureSpawn.csv中字段[animation_default]位置不对应"); return(false); } if (vecLine[9] != "animation_delay") { Ex.Logger.Log("CreatureSpawn.csv中字段[animation_delay]位置不对应"); return(false); } while (true) { vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if ((int)vecLine.Count == 0) { break; } if ((int)vecLine.Count != (int)10) { return(false); } CreatureSpawnElement member = new CreatureSpawnElement(); member.spawn_id = Convert.ToInt32(vecLine[0]); member.npc_entry_id = Convert.ToInt32(vecLine[1]); member.spawn_map_id = Convert.ToInt32(vecLine[2]); member.spawn_x = Convert.ToSingle(vecLine[3]); member.spawn_y = Convert.ToSingle(vecLine[4]); member.spawn_z = Convert.ToSingle(vecLine[5]); member.refresh_time = Convert.ToInt32(vecLine[6]); member.refresh_type = Convert.ToInt32(vecLine[7]); member.animation_default = vecLine[8]; member.animation_delay = vecLine[9]; member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.spawn_id] = member; } return(true); }
private CreatureSpawnTable() { m_mapElements = new Dictionary <int, CreatureSpawnElement>(); m_emptyItem = new CreatureSpawnElement(); m_vecAllElements = new List <CreatureSpawnElement>(); }
public bool LoadBin(byte[] binContent) { m_mapElements.Clear(); m_vecAllElements.Clear(); int nCol, nRow; int readPos = 0; readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nCol); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nRow); List <string> vecLine = new List <string>(nCol); List <int> vecHeadType = new List <int>(nCol); string tmpStr; int tmpInt; for (int i = 0; i < nCol; i++) { readPos += GameAssist.ReadString(binContent, readPos, out tmpStr); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out tmpInt); vecLine.Add(tmpStr); vecHeadType.Add(tmpInt); } if (vecLine.Count != 10) { Ex.Logger.Log("CreatureSpawn.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "spawn_id") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_id]位置不对应"); return(false); } if (vecLine[1] != "npc_entry_id") { Ex.Logger.Log("CreatureSpawn.csv中字段[npc_entry_id]位置不对应"); return(false); } if (vecLine[2] != "spawn_map_id") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_map_id]位置不对应"); return(false); } if (vecLine[3] != "spawn_x") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_x]位置不对应"); return(false); } if (vecLine[4] != "spawn_y") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_y]位置不对应"); return(false); } if (vecLine[5] != "spawn_z") { Ex.Logger.Log("CreatureSpawn.csv中字段[spawn_z]位置不对应"); return(false); } if (vecLine[6] != "refresh_time") { Ex.Logger.Log("CreatureSpawn.csv中字段[refresh_time]位置不对应"); return(false); } if (vecLine[7] != "refresh_type") { Ex.Logger.Log("CreatureSpawn.csv中字段[refresh_type]位置不对应"); return(false); } if (vecLine[8] != "animation_default") { Ex.Logger.Log("CreatureSpawn.csv中字段[animation_default]位置不对应"); return(false); } if (vecLine[9] != "animation_delay") { Ex.Logger.Log("CreatureSpawn.csv中字段[animation_delay]位置不对应"); return(false); } for (int i = 0; i < nRow; i++) { CreatureSpawnElement member = new CreatureSpawnElement(); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.spawn_id); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.npc_entry_id); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.spawn_map_id); readPos += GameAssist.ReadFloat(binContent, readPos, out member.spawn_x); readPos += GameAssist.ReadFloat(binContent, readPos, out member.spawn_y); readPos += GameAssist.ReadFloat(binContent, readPos, out member.spawn_z); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.refresh_time); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.refresh_type); readPos += GameAssist.ReadString(binContent, readPos, out member.animation_default); readPos += GameAssist.ReadString(binContent, readPos, out member.animation_delay); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.spawn_id] = member; } return(true); }