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++; } }
public void Deserialize(IDynamicPacket packet) { this.ID = packet.ReadInt32(); this.Name = packet.ReadString(); this.MapType = packet.ReadInt32(); this.MapFile = packet.ReadString(); this.MapFilePath = packet.ReadString(); this.DeathMatch_OMG = packet.ReadInt32(); this.PicFile = packet.ReadString(); this.ShopFile = packet.ReadString(); this.PCBgSoundFile = packet.ReadString(); this.PCWarnSoundFile = packet.ReadString(); this.PCToughSoundFile = packet.ReadString(); this.PCNormalSoundFile = packet.ReadString(); this.UnPCBgSoundFile = packet.ReadString(); this.UnPCWarnSoundFile = packet.ReadString(); this.UnPCToughSoundFile = packet.ReadString(); this.UnPCNormalSoundFile = packet.ReadString(); this.LCameraPos = packet.ReadString(); this.LCameraAngle = packet.ReadString(); this.ECameraPos = packet.ReadString(); this.ECameraAngle = packet.ReadString(); this.MapCenterX = packet.ReadFloat(); this.MapCenterY = packet.ReadFloat(); this.MaxX = packet.ReadFloat(); this.MaxY = packet.ReadFloat(); this.MinCameraScale = packet.ReadFloat(); this.MaxCameraScale = packet.ReadFloat(); this.MouseWheelSensitivity = packet.ReadFloat(); this.LeagueBaseDeadEft = packet.ReadInt32(); this.EmpireBaseDeadEft = packet.ReadInt32(); this.MineBaseDeadEft = packet.ReadInt32(); this.TheirBaseDeadEft = packet.ReadInt32(); this.LeagueAttackedEffect = packet.ReadInt32(); this.EmpireAttackedEffect = packet.ReadInt32(); this.LeagueEffectWhenHeroDead = packet.ReadInt32(); this.EmpireEffectWhenHeroDead = packet.ReadInt32(); this.LeagueHighHpEffect = packet.ReadInt32(); this.EmpireHighHpEffect = packet.ReadInt32(); this.LeagueLowHpEffect = packet.ReadInt32(); this.EmpireLowHpEffect = packet.ReadInt32(); this.EmpireBasePos = packet.ReadString(); this.LeagueBasePos = packet.ReadString(); this.ComPos = packet.ReadString(); this.ComSmallPos = packet.ReadString(); }