public bool LoadBin(byte[] binContent) { _MapElements.Clear(); _VecAllElements.Clear(); int nCol, nRow; int readPos = 0; readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out nCol); readPos += HS_ByteRead.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 += HS_ByteRead.ReadString(binContent, readPos, out tmpStr); readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out tmpInt); vecLine.Add(tmpStr); vecHeadType.Add(tmpInt); } if (vecLine.Count != 5) { Debug.Log("MushroomsCfg.json中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "Id") { Debug.Log("MushroomsCfg.json中字段[Id]位置不对应"); return(false); } if (vecLine[1] != "AnimationName") { Debug.Log("MushroomsCfg.json中字段[AnimationName]位置不对应"); return(false); } if (vecLine[2] != "RipeTime") { Debug.Log("MushroomsCfg.json中字段[RipeTime]位置不对应"); return(false); } if (vecLine[3] != "SalePrice") { Debug.Log("MushroomsCfg.json中字段[SalePrice]位置不对应"); return(false); } if (vecLine[4] != "isOk") { Debug.Log("MushroomsCfg.json中字段[isOk]位置不对应"); return(false); } for (int i = 0; i < nRow; i++) { MushroomsCfgElement member = new MushroomsCfgElement(); readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.Id); readPos += HS_ByteRead.ReadString(binContent, readPos, out member.AnimationName); readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.RipeTime); readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.SalePrice); readPos += HS_ByteRead.ReadBool(binContent, readPos, out member.isOk); member.IsValidate = true; _VecAllElements.Add(member); _MapElements[member.Id] = member; } return(true); }
public bool LoadBin(byte[] binContent) { _MapElements.Clear(); _VecAllElements.Clear(); int nCol, nRow; int readPos = 0; readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out nCol); readPos += HS_ByteRead.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 += HS_ByteRead.ReadString(binContent, readPos, out tmpStr); readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out tmpInt); vecLine.Add(tmpStr); vecHeadType.Add(tmpInt); } if (vecLine.Count != 5) { Debug.Log("ScenesCfg.json中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "Id") { Debug.Log("ScenesCfg.json中字段[Id]位置不对应"); return(false); } if (vecLine[1] != "BigImageName") { Debug.Log("ScenesCfg.json中字段[BigImageName]位置不对应"); return(false); } if (vecLine[2] != "SmallImageName") { Debug.Log("ScenesCfg.json中字段[SmallImageName]位置不对应"); return(false); } if (vecLine[3] != "BuyPrice") { Debug.Log("ScenesCfg.json中字段[BuyPrice]位置不对应"); return(false); } if (vecLine[4] != "GrowthMushroomsList") { Debug.Log("ScenesCfg.json中字段[GrowthMushroomsList]位置不对应"); return(false); } for (int i = 0; i < nRow; i++) { ScenesCfgElement member = new ScenesCfgElement(); readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.Id); readPos += HS_ByteRead.ReadString(binContent, readPos, out member.BigImageName); readPos += HS_ByteRead.ReadString(binContent, readPos, out member.SmallImageName); readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.BuyPrice); readPos += HS_ByteRead.ReadString(binContent, readPos, out member.GrowthMushroomsList); member.IsValidate = true; _VecAllElements.Add(member); _MapElements[member.Id] = member; } return(true); }