コード例 #1
0
        public void UpdateItem(string package)
        {
            string newPackage = package.Substring(2);

            if (!string.IsNullOrEmpty(newPackage))
            {
                string[] separator = newPackage.Split('|');

                if (Items.TryGetValue(int.Parse(separator[0]), out Item item))
                {
                    int quantity = int.Parse(separator[1]);

                    item.Quantity = quantity;

                    Items[item.GuidItem].Quantity = quantity;

                    InventoryRefresh?.Invoke();
                }
            }
        }
コード例 #2
0
        public void RemoveItem(string package, int quantity, bool isDeletePackage)
        {
            int.TryParse(package.Substring(2), out int GuidItem);

            if (Items.TryGetValue(GuidItem, out Item deleteItem))
            {
                if (deleteItem.Quantity > quantity)
                {
                    deleteItem.Quantity -= quantity;
                    Items[GuidItem]      = deleteItem;
                }
                else
                {
                    Items.TryRemove(GuidItem, out deleteItem);
                }

                if (isDeletePackage)
                {
                    Account.Send($"Od{deleteItem.GuidItem}|{deleteItem.Quantity}");
                }
                InventoryRefresh?.Invoke();
            }
        }
コード例 #3
0
        public void getInventory(string package)
        {
            Task.Run(() =>
            {
                try
                {
                    foreach (string data in package.Split(';'))
                    {
                        if (!string.IsNullOrEmpty(data))
                        {
                            string[] values = data.Split('~');
                            Item @object    = new Item(data);
                            Items.TryAdd(@object.GuidItem, @object);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }).Wait();

            InventoryRefresh?.Invoke();
        }