public static void OnItemPickedUp(Item item) { if (ItemPickedUp != null) { ItemPickedUp.Invoke(item); } }
public bool TryPickupItem(GameObject groundItem) { if (EmptySlots <= 0 || groundItem == null) { return(false); } int inventoryIndex = System.Array.IndexOf(items, null); items[inventoryIndex] = groundItem; var eventArgs = new SlotStateChangeEventArgs() { InventoryObject = groundItem, SlotIndex = inventoryIndex }; ItemPickedUp?.Invoke(this, eventArgs); if (inventoryIndex == ActiveSlot) { ActiveSlotChanged?.Invoke(this, eventArgs); } groundItem.SetActive(false); return(true); }
public void Pickup(Item item) { _items.Add(item); item.transform.SetParent(_itemRoot); ItemPickedUp?.Invoke(item); Equip(item); }
public virtual async Task PickupItemAsync(IGame game, IItem item) { await Map.RemoveItemAsync(item); _items.Add(item); await item.MarkAsPickedUpAsync(this); if (ItemPickedUp != null) { await ItemPickedUp.Invoke(item, this); } }
public void Pickup(Item item, int?slotPosition = null) { if (slotPosition.HasValue == false) { slotPosition = FindFirstAvailableSlot(); } if (slotPosition.HasValue == false) { return; } _items[slotPosition.Value] = item; item.transform.SetParent(_itemRoot); ItemPickedUp?.Invoke(item); item.WasPickedUp = true; Equip(item); }
public void Pickup(Item item, int?slot = null) { if (slot.HasValue == false) { slot = FindFirstAvailableSlot(); if (slot.HasValue == false) { return; } } // Add the item to our list of items _items[slot.Value] = item; // Child it to this game object item.transform.parent = _itemRoot; // Equip this item Equip(item); // Mark this Item as having been picked up item.WasPickedUp = true; // Notify subscribers that we picked up a new item ItemPickedUp?.Invoke(item); }