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 != 14) { Ex.Logger.Log("CreateRole.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "id") { Ex.Logger.Log("CreateRole.csv中字段[id]位置不对应"); return(false); } if (vecLine[1] != "race") { Ex.Logger.Log("CreateRole.csv中字段[race]位置不对应"); return(false); } if (vecLine[2] != "sex") { Ex.Logger.Log("CreateRole.csv中字段[sex]位置不对应"); return(false); } if (vecLine[3] != "race_name") { Ex.Logger.Log("CreateRole.csv中字段[race_name]位置不对应"); return(false); } if (vecLine[4] != "race_description") { Ex.Logger.Log("CreateRole.csv中字段[race_description]位置不对应"); return(false); } if (vecLine[5] != "race_icon") { Ex.Logger.Log("CreateRole.csv中字段[race_icon]位置不对应"); return(false); } if (vecLine[6] != "desc_occupations") { Ex.Logger.Log("CreateRole.csv中字段[desc_occupations]位置不对应"); return(false); } if (vecLine[7] != "default_gender") { Ex.Logger.Log("CreateRole.csv中字段[default_gender]位置不对应"); return(false); } if (vecLine[8] != "default_male_model") { Ex.Logger.Log("CreateRole.csv中字段[default_male_model]位置不对应"); return(false); } if (vecLine[9] != "default_female_model") { Ex.Logger.Log("CreateRole.csv中字段[default_female_model]位置不对应"); return(false); } if (vecLine[10] != "default_male_id") { Ex.Logger.Log("CreateRole.csv中字段[default_male_id]位置不对应"); return(false); } if (vecLine[11] != "default_female_id") { Ex.Logger.Log("CreateRole.csv中字段[default_female_id]位置不对应"); return(false); } if (vecLine[12] != "male_role_id") { Ex.Logger.Log("CreateRole.csv中字段[male_role_id]位置不对应"); return(false); } if (vecLine[13] != "female_role_id") { Ex.Logger.Log("CreateRole.csv中字段[female_role_id]位置不对应"); return(false); } while (true) { vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if ((int)vecLine.Count == 0) { break; } if ((int)vecLine.Count != (int)14) { return(false); } CreateRoleElement member = new CreateRoleElement(); member.id = Convert.ToInt32(vecLine[0]); member.race = Convert.ToInt32(vecLine[1]); member.sex = vecLine[2]; member.race_name = Convert.ToInt32(vecLine[3]); member.race_description = Convert.ToInt32(vecLine[4]); member.race_icon = vecLine[5]; member.desc_occupations = Convert.ToInt32(vecLine[6]); member.default_gender = Convert.ToInt32(vecLine[7]); member.default_male_model = Convert.ToInt32(vecLine[8]); member.default_female_model = Convert.ToInt32(vecLine[9]); member.default_male_id = Convert.ToInt32(vecLine[10]); member.default_female_id = Convert.ToInt32(vecLine[11]); member.male_role_id = vecLine[12]; member.female_role_id = vecLine[13]; member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.id] = member; } return(true); }
private CreateRoleTable() { m_mapElements = new Dictionary <int, CreateRoleElement>(); m_emptyItem = new CreateRoleElement(); m_vecAllElements = new List <CreateRoleElement>(); }
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 != 14) { Ex.Logger.Log("CreateRole.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "id") { Ex.Logger.Log("CreateRole.csv中字段[id]位置不对应"); return(false); } if (vecLine[1] != "race") { Ex.Logger.Log("CreateRole.csv中字段[race]位置不对应"); return(false); } if (vecLine[2] != "sex") { Ex.Logger.Log("CreateRole.csv中字段[sex]位置不对应"); return(false); } if (vecLine[3] != "race_name") { Ex.Logger.Log("CreateRole.csv中字段[race_name]位置不对应"); return(false); } if (vecLine[4] != "race_description") { Ex.Logger.Log("CreateRole.csv中字段[race_description]位置不对应"); return(false); } if (vecLine[5] != "race_icon") { Ex.Logger.Log("CreateRole.csv中字段[race_icon]位置不对应"); return(false); } if (vecLine[6] != "desc_occupations") { Ex.Logger.Log("CreateRole.csv中字段[desc_occupations]位置不对应"); return(false); } if (vecLine[7] != "default_gender") { Ex.Logger.Log("CreateRole.csv中字段[default_gender]位置不对应"); return(false); } if (vecLine[8] != "default_male_model") { Ex.Logger.Log("CreateRole.csv中字段[default_male_model]位置不对应"); return(false); } if (vecLine[9] != "default_female_model") { Ex.Logger.Log("CreateRole.csv中字段[default_female_model]位置不对应"); return(false); } if (vecLine[10] != "default_male_id") { Ex.Logger.Log("CreateRole.csv中字段[default_male_id]位置不对应"); return(false); } if (vecLine[11] != "default_female_id") { Ex.Logger.Log("CreateRole.csv中字段[default_female_id]位置不对应"); return(false); } if (vecLine[12] != "male_role_id") { Ex.Logger.Log("CreateRole.csv中字段[male_role_id]位置不对应"); return(false); } if (vecLine[13] != "female_role_id") { Ex.Logger.Log("CreateRole.csv中字段[female_role_id]位置不对应"); return(false); } for (int i = 0; i < nRow; i++) { CreateRoleElement member = new CreateRoleElement(); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.id); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.race); readPos += GameAssist.ReadString(binContent, readPos, out member.sex); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.race_name); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.race_description); readPos += GameAssist.ReadString(binContent, readPos, out member.race_icon); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.desc_occupations); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.default_gender); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.default_male_model); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.default_female_model); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.default_male_id); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.default_female_id); readPos += GameAssist.ReadString(binContent, readPos, out member.male_role_id); readPos += GameAssist.ReadString(binContent, readPos, out member.female_role_id); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.id] = member; } return(true); }