Example #1
0
        /// <summary>
        /// Removes an item from the inventory.
        /// </summary>
        /// <param name="item">Item to remove.</param>
        public void Remove(Item item)
        {
            if (item == null)
            {
                return;
            }

            InventoryList.Remove(item);
        }
Example #2
0
        private async Task OnRemoveInventory(object param)
        {
            if (param is Inventory)
            {
                await inventoryRepo.DeleteInventoryAsync((param as Inventory).Id);

                InventoryList.Remove(InventoryList.FirstOrDefault(x => x.Id == (param as Inventory).Id));
                alertService.Show("Usuwanie towaru", $"Usunięto towar {(param as Inventory).Name}", "Zamknij");
            }
        }
Example #3
0
        public void Buy(IItem item, int quantity = 1)
        {
            if (!CanBuy(item))
            {
                throw new ArgumentException("Ошибка при покупке предмета.");
            }

            Player.Inventory.Gold -= GetBuyGoldCost(item, quantity);
            var itemToAdd = item.Clone();

            itemToAdd.Quantity = quantity;
            Player.InventoryService.Add(itemToAdd);

            _sellingItems.Remove(item, quantity);
        }
 public void Remove(IItem item, int quantity = 1)
 {
     if (BagContains(item))
     {
         _bag.Remove(item, quantity);
     }
     else if (item == Inventory.SoulShot)
     {
         item.Quantity -= Math.Min(item.Quantity, quantity);
     }
     else if (IsEquipped(item))
     {
         item.Quantity -= quantity;
         if (item.Quantity <= 0)
         {
             Inventory.EquippedItems.Remove(item);
         }
     }
 }
Example #5
0
 private void InventoryDeleteEventHandler(object sender, InventoryDeleteEventArgs args)
 {
     InventoryList.Remove(args.Inventory);
 }
        public override async void OnNavigatedTo(INavigationParameters parameters)
        {
            try
            {
                if (parameters.ContainsKey("inventoryList"))
                {
                    List <InventoryThumbnail> inventoryList = (List <InventoryThumbnail>)parameters["inventoryList"];

                    foreach (var inventoryThumbnail in inventoryList)
                    {
                        var wrappedInventory = InventoryList.FirstOrDefault(x => x.Item.inventory_id == inventoryThumbnail.inventory_id);
                        if (wrappedInventory == null)
                        {
                            WrappedSelection <InventoryThumbnail> temp = new WrappedSelection <InventoryThumbnail>()
                            {
                                Item = inventoryThumbnail, IsSelected = false
                            };
                            InventoryList.Add(temp);
                        }
                        else
                        {
                            int index = _inventoryList.IndexOf(wrappedInventory);
                            InventoryList.Remove(wrappedInventory);
                            InventoryList.Insert(index, new WrappedSelection <InventoryThumbnail> {
                                Item = inventoryThumbnail, IsSelected = wrappedInventory.IsSelected
                            });
                        }
                    }

                    AccessionCount = InventoryList.Select(i => i.Item.accession_id).Distinct().Count();
                }
                if (parameters.ContainsKey("InventoryThumbnail"))
                {
                    InventoryThumbnail inventoryThumbnail = (InventoryThumbnail)parameters["InventoryThumbnail"];

                    WrappedSelection <InventoryThumbnail> inventoryThumbnailItem = _inventoryList.FirstOrDefault(item => item.Item.inventory_id == inventoryThumbnail.inventory_id);
                    if (inventoryThumbnailItem == null)
                    {
                        InventoryList.Add(new WrappedSelection <InventoryThumbnail> {
                            Item = inventoryThumbnail, IsSelected = false
                        });
                    }
                    else
                    {
                        int index = InventoryList.IndexOf(inventoryThumbnailItem);
                        InventoryList.Remove(inventoryThumbnailItem);
                        InventoryList.Insert(index, new WrappedSelection <InventoryThumbnail> {
                            Item = inventoryThumbnail, IsSelected = false
                        });
                    }
                }
                if (parameters.ContainsKey("message"))
                {
                    await _pageDialogService.DisplayAlertAsync("Message", (string)parameters["message"], "OK");
                }
            }
            catch (Exception ex)
            {
                await _pageDialogService.DisplayAlertAsync("Error", ex.Message, "OK");
            }
        }