private QiangHuaTable() { m_mapElements = new Dictionary <int, QiangHuaElement>(); m_emptyItem = new QiangHuaElement(); m_vecAllElements = new List <QiangHuaElement>(); }
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 != 6) { Ex.Logger.Log("QiangHua.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "LVID") { Ex.Logger.Log("QiangHua.csv中字段[LVID]位置不对应"); return(false); } if (vecLine[1] != "Num") { Ex.Logger.Log("QiangHua.csv中字段[Num]位置不对应"); return(false); } if (vecLine[2] != "GaiLv") { Ex.Logger.Log("QiangHua.csv中字段[GaiLv]位置不对应"); return(false); } if (vecLine[3] != "Item") { Ex.Logger.Log("QiangHua.csv中字段[Item]位置不对应"); return(false); } if (vecLine[4] != "ItemNum") { Ex.Logger.Log("QiangHua.csv中字段[ItemNum]位置不对应"); return(false); } if (vecLine[5] != "ZhuanYi") { Ex.Logger.Log("QiangHua.csv中字段[ZhuanYi]位置不对应"); return(false); } for (int i = 0; i < nRow; i++) { QiangHuaElement member = new QiangHuaElement(); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.LVID); readPos += GameAssist.ReadString(binContent, readPos, out member.Num); readPos += GameAssist.ReadString(binContent, readPos, out member.GaiLv); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Item); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ItemNum); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ZhuanYi); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.LVID] = member; } return(true); }
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 != 6) { Ex.Logger.Log("QiangHua.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "LVID") { Ex.Logger.Log("QiangHua.csv中字段[LVID]位置不对应"); return(false); } if (vecLine[1] != "Num") { Ex.Logger.Log("QiangHua.csv中字段[Num]位置不对应"); return(false); } if (vecLine[2] != "GaiLv") { Ex.Logger.Log("QiangHua.csv中字段[GaiLv]位置不对应"); return(false); } if (vecLine[3] != "Item") { Ex.Logger.Log("QiangHua.csv中字段[Item]位置不对应"); return(false); } if (vecLine[4] != "ItemNum") { Ex.Logger.Log("QiangHua.csv中字段[ItemNum]位置不对应"); return(false); } if (vecLine[5] != "ZhuanYi") { Ex.Logger.Log("QiangHua.csv中字段[ZhuanYi]位置不对应"); return(false); } while (true) { vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if ((int)vecLine.Count == 0) { break; } if ((int)vecLine.Count != (int)6) { return(false); } QiangHuaElement member = new QiangHuaElement(); member.LVID = Convert.ToInt32(vecLine[0]); member.Num = vecLine[1]; member.GaiLv = vecLine[2]; member.Item = Convert.ToInt32(vecLine[3]); member.ItemNum = Convert.ToInt32(vecLine[4]); member.ZhuanYi = Convert.ToInt32(vecLine[5]); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.LVID] = member; } return(true); }