public static Backpack_GoodsChangeReturnProto GetProto(byte[] buffer) { Backpack_GoodsChangeReturnProto proto = new Backpack_GoodsChangeReturnProto(); MMO_MemoryStream ms = GameEntry.Socket.SocketReceiveMS; ms.SetLength(0); ms.Write(buffer, 0, buffer.Length); ms.Position = 0; proto.BackpackItemChangeCount = ms.ReadInt(); proto.ItemList = new List <ChangeItem>(); for (int i = 0; i < proto.BackpackItemChangeCount; i++) { ChangeItem _Item = new ChangeItem(); _Item.BackpackId = ms.ReadInt(); _Item.ChangeType = (byte)ms.ReadByte(); _Item.GoodsType = (byte)ms.ReadByte(); _Item.GoodsId = ms.ReadInt(); _Item.GoodsCount = ms.ReadInt(); _Item.GoodsServerId = ms.ReadInt(); proto.ItemList.Add(_Item); } return(proto); }
public static void OnBackpack_GoodsChangeReturn(byte[] buffer) { Backpack_GoodsChangeReturnProto proto = Backpack_GoodsChangeReturnProto.GetProto(buffer); #if DEBUG_LOG_PROTO Debug.Log("<color=#00eaff>接收消息:</color><color=#00ff9c>" + proto.ProtoEnName + " " + proto.ProtoCode + "</color>"); Debug.Log("<color=#c5e1dc>==>>" + JsonUtility.ToJson(proto) + "</color>"); #endif }
public static Backpack_GoodsChangeReturnProto GetProto(byte[] buffer) { Backpack_GoodsChangeReturnProto proto = new Backpack_GoodsChangeReturnProto(); using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer)) { proto.BackpackItemChangeCount = ms.ReadInt(); proto.ItemList = new List <ChangeItem>(); for (int i = 0; i < proto.BackpackItemChangeCount; i++) { ChangeItem _Item = new ChangeItem(); _Item.BackpackId = ms.ReadInt(); _Item.ChangeType = (byte)ms.ReadByte(); _Item.GoodsType = (byte)ms.ReadByte(); _Item.GoodsId = ms.ReadInt(); _Item.GoodsCount = ms.ReadInt(); _Item.GoodsServerId = ms.ReadInt(); proto.ItemList.Add(_Item); } } return(proto); }
public static Backpack_GoodsChangeReturnProto GetProto(byte[] buffer, bool isChild = false) { Backpack_GoodsChangeReturnProto proto = new Backpack_GoodsChangeReturnProto(); MMO_MemoryStream ms = null; if (!isChild) { ms = GameEntry.Socket.SocketSendMS; } else { ms = GameEntry.Pool.DequeueClassObject <MMO_MemoryStream>(); } ms.SetLength(0); ms.Write(buffer, 0, buffer.Length); ms.Position = 0; proto.BackpackItemChangeCount = ms.ReadInt(); proto.ItemList = new List <ChangeItem>(); for (int i = 0; i < proto.BackpackItemChangeCount; i++) { ChangeItem _Item = new ChangeItem(); _Item.BackpackId = ms.ReadInt(); _Item.ChangeType = (byte)ms.ReadByte(); _Item.GoodsType = (byte)ms.ReadByte(); _Item.GoodsId = ms.ReadInt(); _Item.GoodsCount = ms.ReadInt(); _Item.GoodsServerId = ms.ReadInt(); proto.ItemList.Add(_Item); } if (isChild) { GameEntry.Pool.EnqueueClassObject(ms); } return(proto); }