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 != 8) { Debug.Log("HeroJiBan.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "JBID") { Debug.Log("HeroJiBan.csv中字段[JBID]位置不对应"); return(false); } if (vecLine[1] != "Name") { Debug.Log("HeroJiBan.csv中字段[Name]位置不对应"); return(false); } if (vecLine[2] != "Hero") { Debug.Log("HeroJiBan.csv中字段[Hero]位置不对应"); return(false); } if (vecLine[3] != "Des") { Debug.Log("HeroJiBan.csv中字段[Des]位置不对应"); return(false); } if (vecLine[4] != "Type") { Debug.Log("HeroJiBan.csv中字段[Type]位置不对应"); return(false); } if (vecLine[5] != "Cond") { Debug.Log("HeroJiBan.csv中字段[Cond]位置不对应"); return(false); } if (vecLine[6] != "Attr") { Debug.Log("HeroJiBan.csv中字段[Attr]位置不对应"); return(false); } if (vecLine[7] != "Num") { Debug.Log("HeroJiBan.csv中字段[Num]位置不对应"); return(false); } while (true) { vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if ((int)vecLine.Count == 0) { break; } if ((int)vecLine.Count != (int)8) { return(false); } HeroJiBanElement member = new HeroJiBanElement(); member.JBID = Convert.ToInt32(vecLine[0]); member.Name = vecLine[1]; member.Hero = Convert.ToInt32(vecLine[2]); member.Des = vecLine[3]; member.Type = Convert.ToInt32(vecLine[4]); member.Cond = vecLine[5]; member.Attr = Convert.ToInt32(vecLine[6]); member.Num = Convert.ToSingle(vecLine[7]); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.JBID] = member; } return(true); }
private HeroJiBanTable() { m_mapElements = new Dictionary <int, HeroJiBanElement>(); m_emptyItem = new HeroJiBanElement(); m_vecAllElements = new List <HeroJiBanElement>(); }
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 != 8) { Debug.Log("HeroJiBan.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "JBID") { Debug.Log("HeroJiBan.csv中字段[JBID]位置不对应"); return(false); } if (vecLine[1] != "Name") { Debug.Log("HeroJiBan.csv中字段[Name]位置不对应"); return(false); } if (vecLine[2] != "Hero") { Debug.Log("HeroJiBan.csv中字段[Hero]位置不对应"); return(false); } if (vecLine[3] != "Des") { Debug.Log("HeroJiBan.csv中字段[Des]位置不对应"); return(false); } if (vecLine[4] != "Type") { Debug.Log("HeroJiBan.csv中字段[Type]位置不对应"); return(false); } if (vecLine[5] != "Cond") { Debug.Log("HeroJiBan.csv中字段[Cond]位置不对应"); return(false); } if (vecLine[6] != "Attr") { Debug.Log("HeroJiBan.csv中字段[Attr]位置不对应"); return(false); } if (vecLine[7] != "Num") { Debug.Log("HeroJiBan.csv中字段[Num]位置不对应"); return(false); } for (int i = 0; i < nRow; i++) { HeroJiBanElement member = new HeroJiBanElement(); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.JBID); readPos += GameAssist.ReadString(binContent, readPos, out member.Name); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Hero); readPos += GameAssist.ReadString(binContent, readPos, out member.Des); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Type); readPos += GameAssist.ReadString(binContent, readPos, out member.Cond); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Attr); readPos += GameAssist.ReadFloat(binContent, readPos, out member.Num); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.JBID] = member; } return(true); }