void OnLoadBtn() { if (mFileName.text == "") { return; } string _strFilePath = GameConfig.GetUserDataPath() + "/PlanetExplorers/Building/"; if (!Directory.Exists(_strFilePath)) { Directory.CreateDirectory(_strFilePath); } for (int i = 0; i < mItemList.Count; i++) { Destroy(mItemList[i].gameObject); } mItemList.Clear(); for (int i = 0; i < mNpcList.Count; i++) { Destroy(mNpcList[i].gameObject); } mNpcList.Clear(); if (null != Block45Man.self.DataSource) { Block45Man.self.DataSource.Clear(); } if (File.Exists(_strFilePath + mFileName.text + ".txt")) { using (FileStream _fileStream = new FileStream(_strFilePath + mFileName.text + ".txt", FileMode.Open, FileAccess.Read)) { BinaryReader _in = new BinaryReader(_fileStream); int readVersion = _in.ReadInt32(); switch (readVersion) { case 2: int Size = _in.ReadInt32(); for (int i = 0; i < Size; i++) { IntVector3 index = new IntVector3(_in.ReadInt32(), _in.ReadInt32(), _in.ReadInt32()); Block45Man.self.DataSource.SafeWrite(new B45Block(_in.ReadByte(), _in.ReadByte()), index.x, index.y, index.z, 0); } break; } _in.Close(); } } if (File.Exists(_strFilePath + mFileName.text + "SubInfo.txt")) { using (FileStream _fileStream = new FileStream(_strFilePath + mFileName.text + "SubInfo.txt", FileMode.Open, FileAccess.Read)) { BinaryReader _in = new BinaryReader(_fileStream); int version = _in.ReadInt32(); int count = _in.ReadInt32(); switch (version) { case 1: for (int i = 0; i < count; i++) { Vector3 npcPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.NpcSetting; // req.mReq = AssetBundlesMan.Instance.AddReq("Model/PlayerModel/Male", npcPos, Quaternion.identity); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load("Model/PlayerModel/Male")) as GameObject; obj.transform.position = npcPos; CreateMode(obj, req); } break; case 2: for (int i = 0; i < count; i++) { Vector3 npcPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.NpcSetting; // req.mReq = AssetBundlesMan.Instance.AddReq("Model/PlayerModel/Male", npcPos, Quaternion.identity); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load("Model/PlayerModel/Male")) as GameObject; obj.transform.position = npcPos; CreateMode(obj, req); } count = _in.ReadInt32(); for (int i = 0; i < count; i++) { Vector3 itemPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); Quaternion ItemRot = Quaternion.Euler(new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle())); int itemID = _in.ReadInt32(); ItemProto itemData = ItemProto.GetItemData(itemID); if (null == itemData || !itemData.IsBlock()) { continue; } CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.ItemSetting; req.mItemId = itemID; // req.mReq = AssetBundlesMan.Instance.AddReq(ItemData.GetItemData(itemID).m_ModelPath, itemPos, ItemRot); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load(ItemProto.GetItemData(itemID).resourcePath)) as GameObject; obj.transform.position = itemPos; obj.transform.localRotation = ItemRot; CreateMode(obj, req); // CreateMode(Instantiate(Resources.Load(ItemData.GetItemData(itemID).m_ModelPath)) as GameObject, req); } break; } _in.Close(); } } }