private bool LoadCSV() { string fullPath = ResourceManager.GetFullPath(m_DataFile.ToLower(), false); bool result; if (!File.Exists(fullPath)) { result = false; } else { FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read); BinaryReader binaryReader = new BinaryReader(fileStream); //读取是不是csv的文件,如果是的话,就加载。防止被别人修改数据 if (binaryReader.ReadString() != "chenfuling") { binaryReader.Close(); fileStream.Close(); result = false; } else { //先读取所有数据的总大小,然后读取byte[]数据 IDynamicPacket dynamicPacket = DynamicPacket.Create(binaryReader.ReadBytes(binaryReader.ReadInt32())); //在byte[]数据里面,先读取多少份不同类型的数据 int num = dynamicPacket.ReadInt32(); int i = 0; while (i < num) { //读取这份类型数据的总大小 int size = dynamicPacket.ReadInt32(); //根据大小读取这份数据byte[] IDynamicPacket subPacket = DynamicPacket.Create(dynamicPacket.ReadBytes(size)); //读取出这份类型的数据类型字符串 string type = subPacket.ReadString(); //根据类型,解析出数据 switch (type) { case "table\\map\\maplist.csv": //根据ushort的数量大小,再解析出List<T>数据 //DataMaplistManager.Instance.Deserialize(subPacket); break; } i++; } binaryReader.Close(); fileStream.Close(); result = true; } } return(result); }
void Start() { StringFileReader sfr = new StringFileReader(); FileStream fs = new FileStream("F://chenfuling/龙翼编年史/龙翼编年史/bin/" + path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); Debug.Log(br.ReadString()); Debug.Log(br.ReadUInt32()); int a = br.ReadInt32(); Debug.Log(a); byte[] a1 = br.ReadBytes(a); IDynamicPacket packet = DynamicPacket.Create(a1); int num = packet.ReadInt32(); Debug.Log(num); int i = 0; while (i < num) { int count = packet.ReadInt32(); Debug.Log("count:" + count); IDynamicPacket packet2 = DynamicPacket.Create(packet.ReadBytes(count)); string text = packet2.ReadString(); switch (text) { case "table\\herolist.csv": //DataBeastlistManager.Instance.Deserialize(packet2); //DataHerolistManager.Instance.CorrectString(reader); // Debug.Log(DataBeastlistManager.Instance.DataList[0].StrategyDesc); break; case "table\\map\\maplist.csv": DataMaplistManager.Instance.Deserialize(packet2); break; } i++; } }