public new void PacketBytesToClass(byte[] data) { Type infotype = this.GetType(); FieldInfo headerinfo = null; int index = ParsePacketHeader(data); // eResult byte[] itemCount = new byte[sizeof(Int32)]; headerinfo = infotype.GetField("eResult", BINDING_FLAGS_PIG); Buffer.BlockCopy(data, index, itemCount, 0, sizeof(Int32)); headerinfo.SetValue(this, BitConverter.ToInt32(itemCount, 0)); index += sizeof(Int32); // nBody2Cnt byte[] itemCnt = new byte[sizeof(Int32)]; headerinfo = infotype.GetField("nBody2Cnt", BINDING_FLAGS_PIG); Buffer.BlockCopy(data, index, itemCnt, 0, sizeof(Int32)); headerinfo.SetValue(this, BitConverter.ToInt32(itemCnt, 0)); index += sizeof(Int32); body = new body2_SC_SHOP_INFO[nBody2Cnt]; for (int i = 0; i < nBody2Cnt; i++) { body[i] = new body2_SC_SHOP_INFO(); byte[] tmpData = new byte[body2_SC_SHOP_INFO.size]; Buffer.BlockCopy(data, index, tmpData, 0, tmpData.Length); body[i].ByteArrayToClass(tmpData); index += body2_SC_SHOP_INFO.size; } }
/// <summary> /// process shop infoes from server /// </summary> /// <param name="_shopInfos"></param> public void ProcessNpcShopInfo(body2_SC_SHOP_INFO[] _shopInfoes) { dicShopInfo.Clear(); foreach (body2_SC_SHOP_INFO info in _shopInfoes) { if (!dicShopInfo.ContainsKey(info.nShopItemSlot)) dicShopInfo.Add(info.nShopItemSlot, info); Debug.LogWarning(info.ToString()); } UpdateStoreInfo(); classTypeBtn.controlIsEnabled = true; if (loadingGear != null) loadingGear.SetActive(false); LockInput(false); }