Beispiel #1
0
        public byte[] BuyItem(byte[] data)
        {
            var inputStream  = new MemoryStream(data);
            var itemId       = Int32Proxy.Deserialize(inputStream);
            var authToken    = Encoding.UTF8.GetString(Convert.FromBase64String(StringProxy.Deserialize(inputStream)));
            var currencyType = EnumProxy <UberStrikeCurrencyType> .Deserialize(inputStream);

            var itemType = EnumProxy <UberstrikeItemType> .Deserialize(inputStream);

            var buyingLocationType = EnumProxy <BuyingLocationType> .Deserialize(inputStream);

            var buyingRecommendationType = EnumProxy <BuyingRecommendationType> .Deserialize(inputStream);

            var outputStream = new MemoryStream();

            if (inventoryData.ContainsKey(authToken))
            {
                var item = new ItemInventoryView {
                    ItemId          = itemId,
                    AmountRemaining = itemType != UberstrikeItemType.QuickUse ? -1 : 50
                };
                inventoryData[authToken].Add(item);

                UpdateInventoryData();

                Int32Proxy.Serialize(outputStream, (int)BuyItemResult.OK);
            }
            else
            {
                Int32Proxy.Serialize(outputStream, (int)BuyItemResult.InvalidMember);
            }

            return(outputStream.ToArray());
        }
Beispiel #2
0
        // Token: 0x06001054 RID: 4180 RVA: 0x00013A58 File Offset: 0x00011C58
        public static ItemInventoryView Deserialize(Stream bytes)
        {
            int num = Int32Proxy.Deserialize(bytes);
            ItemInventoryView itemInventoryView = new ItemInventoryView();

            itemInventoryView.AmountRemaining = Int32Proxy.Deserialize(bytes);
            itemInventoryView.Cmid            = Int32Proxy.Deserialize(bytes);
            if ((num & 1) != 0)
            {
                itemInventoryView.ExpirationDate = new DateTime?(DateTimeProxy.Deserialize(bytes));
            }
            itemInventoryView.ItemId = Int32Proxy.Deserialize(bytes);
            return(itemInventoryView);
        }
        public static ItemInventoryView Deserialize(Stream bytes)
        {
            int mask = Int32Proxy.Deserialize(bytes);
            var view = new ItemInventoryView();

            view.AmountRemaining = Int32Proxy.Deserialize(bytes);
            view.Cmid            = Int32Proxy.Deserialize(bytes);

            if ((mask & 1) != 0)
            {
                view.ExpirationDate = new DateTime?(DateTimeProxy.Deserialize(bytes));
            }

            view.ItemId = Int32Proxy.Deserialize(bytes);
            return(view);
        }
        public static void Serialize(Stream stream, ItemInventoryView instance)
        {
            int mask = 0;

            using (var bytes = new MemoryStream())
            {
                Int32Proxy.Serialize(bytes, instance.AmountRemaining);
                Int32Proxy.Serialize(bytes, instance.Cmid);

                if (instance.ExpirationDate.HasValue)
                {
                    DateTimeProxy.Serialize(bytes, (!instance.ExpirationDate.HasValue) ? default(DateTime) : instance.ExpirationDate.Value);
                }
                else
                {
                    mask |= 1;
                }

                Int32Proxy.Serialize(bytes, instance.ItemId);
                Int32Proxy.Serialize(stream, ~mask);
                bytes.WriteTo(stream);
            }
        }
Beispiel #5
0
        // Token: 0x06001053 RID: 4179 RVA: 0x000139A0 File Offset: 0x00011BA0
        public static void Serialize(Stream stream, ItemInventoryView instance)
        {
            int num = 0;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                Int32Proxy.Serialize(memoryStream, instance.AmountRemaining);
                Int32Proxy.Serialize(memoryStream, instance.Cmid);
                if (instance.ExpirationDate != null)
                {
                    Stream   bytes          = memoryStream;
                    DateTime?expirationDate = instance.ExpirationDate;
                    DateTimeProxy.Serialize(bytes, (expirationDate == null) ? default(DateTime) : expirationDate.Value);
                }
                else
                {
                    num |= 1;
                }
                Int32Proxy.Serialize(memoryStream, instance.ItemId);
                Int32Proxy.Serialize(stream, ~num);
                memoryStream.WriteTo(stream);
            }
        }