void OnItemSelected() { if (onItemEvent != null) { onItemEvent.Invoke("OnItemSelected"); } }
/// <summary> /// Publishes current potions and ammo to gui /// </summary> private void PublishSelectedItems() { Item potionToPublish = null; if (selectedPotionUuid.Length > 0 && inventory.ContainsKey(selectedPotionUuid)) { potionToPublish = inventory[selectedPotionUuid]; } else { potionToPublish = new Item(); potionToPublish.uuid = EMPTY_POTION; } eventItem.Invoke(potionToPublish); Item ammoToPublish = null; if (selectedAmmoUuid.Length > 0 && inventory.ContainsKey(selectedAmmoUuid)) { ammoToPublish = inventory[selectedPotionUuid]; } else { ammoToPublish = new Item(); ammoToPublish.uuid = EMPTY_AMMO; } eventItem.Invoke(ammoToPublish); }
public void SetItem(Item item, int count) { CurrentItem = item; CurrentItemCount = count; OnItemGet.Invoke(item); OnItemCountChange.Invoke(count); }
/// <summary> /// Notify to the inventory about a click on an item holder. /// </summary> /// <param name="holder"></param> public void NotifyClick(ItemHolder holder) { if (m_inventory.SelectedItem == holder) { return; } //Retrieve a reference to the holder inside the inventory var itemInInventory = Items.First((e) => e == holder); if (itemInInventory == null) { return; } //Show the selector var itemTransform = itemInInventory.transform; m_Selector.transform.position = itemTransform.position; m_Selector.SetActive(true); //Update the internal state of the Inventory m_inventory.SelectItem(holder.m_index); if (m_InfoLabelCoroutine != null) { StopCoroutine(m_InfoLabelCoroutine); } m_InfoLabelCoroutine = StartCoroutine(InfoLabelAnimation(holder.Item.Name)); //Notify to all listeners OnItemSelected.Invoke(m_inventory.SelectedItem.Item); }
public void AttemptUseItem() { if (currentItem != null) { OnUseItem.Invoke(currentItem); } }
/// <summary> /// Add a new Item inside the inventory /// </summary> public void AddItem(Item newItem) { //Notify to all listeners m_inventory.AddItem(newItem); OnItemAdded.Invoke(newItem); }
// This function is called by the LostItemReaction in order to remove an item from the inventory. public void RemoveItem(Item itemToRemove, float quantity = 1) { //If item is not present in inventory, inform and return if (!items.Contains(itemToRemove)) { Debug.LogWarning("No item found to remove in Inventory: " + name + " with name: " + itemToRemove.name); return; } //Handle Item quantity only if it is stackable if (itemToRemove.isStackable) { float newQuantity = itemToRemove.currentQuantity - quantity; itemToRemove.currentQuantity = (newQuantity <= 0) ? 0 : newQuantity; //inventoryGUI.resetItemQuantity(itemToRemove); //remove the item from the inventory if the quantity is zero and is marked as removeIfEmpty if (itemToRemove.currentQuantity == 0 && itemToRemove.removeIfEmpty) { items.Remove(itemToRemove); } return; } // Remove the Item (isUnique or non stackable Item cases) items.Remove(itemToRemove); OnRemoveItem.Invoke(itemToRemove); //inventoryGUI.removeItem(itemToRemove); }
public virtual void AddItem(T item) { if (!Items.Contains(item)) { Items.Add(item); OnAddItem.Invoke(item); } }
public virtual void RemoveItem(T item) { if (Items.Contains(item)) { Items.Remove(item); OnRemoveItem.Invoke(item); } }
public void AttemptDrop() { if (currentItem != null) { currentItem.Drop(this); OnDropItem.Invoke(currentItem); } }
public virtual void UIClicked(ItemUI iui) { itemSelected.Invoke(iui.item); // referece to the item linked to the invoked ItemUI //Inventory.playerInventory.Add(iui.item); //inventory.Remove(iui.item); //Destroy(iui.gameObject); }
public void HandleLootboxItemClicked(Item item) { if (!item.TryEquip(character)) { items.Add(item); OnItemAddedToInventory.Invoke(item); } }
public virtual void UIClicked(ItemUI iui) { itemSelected.Invoke(iui.item); //Inventory.playerInventory.Add(iui.item); //inventory.Remove(iui.item); Destroy(iui.gameObject); }
public void TriggerItemEvent(CollectibleItem.ItemID id, int amt) { if (id == CollectibleItem.ItemID.Invalid || id == CollectibleItem.ItemID.kCount) { Debug.LogError("Triggering Item Event with invalid id: " + id); return; } m_itemGainedEvent.Invoke(id, amt); }
public void UseItem() { if (CurrentItemCount > 0 && CurrentItem != null && CanUseItem && !Input.GetButton(Constants.Input.ActivateAbilityKeyboard)) { InstantiateItem(); SetCount(CurrentItemCount - 1); OnItemUse.Invoke(CurrentItem); StartCoroutine(AntiSpamRoutine()); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player" && other.GetComponent <BackPackBehaviour>().Items.Count < other.GetComponent <BackPackBehaviour>().Capacity) { print("Collision"); ItemBehaviour b = this.GetComponent <ItemBehaviour>(); OnEvent.Invoke(b.ItemRuntime); other.gameObject.GetComponent <BackPackBehaviour>().AddItem(b.ItemRuntime); Destroy(Prefab); } }
public static void declancherEvenement(string nomEvenement, int idObjet, string nomJoueur) { ItemEvent evenement = null; dictionnaireEvenement.TryGetValue(nomEvenement, out evenement); if (evenement != null) { evenement.Invoke(idObjet, nomJoueur); } else { Debug.LogError(nomEvenement + " existe pas"); } }
/*--------------------------------------------------------------------------------------------*/ public void RemoveItem(HoverItem pItem) { if (vItems == null) { return; } if (!vItems.Remove(pItem)) { Debug.LogWarning("Cannot remove missing item '" + pItem.name + "'.", pItem); return; } OnItemRemoved.Invoke(pItem); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void AddItem(HoverItem pItem) { if (vItems == null) { return; } if (vItems.Contains(pItem)) { Debug.LogWarning("Cannot add duplicate item '" + pItem.name + "'.", pItem); return; } vItems.Add(pItem); OnItemAdded.Invoke(pItem); }
private void OnTriggerEnter(Collider other) { if (other.tag == "Item") { gotItem.Invoke(other.GetComponent <ItemScript>().getTypeOfItem(), other.transform.position); foreach (GameObject item in gm.IC.SpawnedItems) { if (item == other.transform.parent.gameObject) { gm.IC.SpawnedItems.Remove(item); break; } } Destroy(other.transform.parent.gameObject); } }
// This function is called by the PickedUpItemReaction in order to add an item to the inventory. public void AddItem(Item itemToAdd, float quantity = 1) { if (!isValidItem(itemToAdd)) { return; } // The item is already present in the inventory if (items.Contains(itemToAdd)) { // is Unique if (itemToAdd.isUnique) { Debug.Log("The item: " + itemToAdd.name + " is tagged as Unique and is already present in the inventory: " + this.inventoryItemList.name); } // Stackable Object if (itemToAdd.isStackable) { float quantityToAdd = itemToAdd.currentQuantity + quantity; itemToAdd.currentQuantity = (quantityToAdd >= itemToAdd.maxQuantity) ? itemToAdd.maxQuantity : quantityToAdd; //inventoryGUI.resetItemQuantity(itemToAdd); } return; } // Inventory is full if (fixedSize && items.Count == numItemSlots) { return; } // If we get here, it means that item can be added to the inventory items.Add(itemToAdd); OnAddItem.Invoke(itemToAdd); // inventoryGUI.addItem(itemToAdd); }
/*--------------------------------------------------------------------------------------------*/ private void UpdateWithLatestItemTypeIfNeeded() { if (_ItemType == vPrevItemType) { return; } HoverItemData newData = BuildData(_ItemType); TransferData(newData); DestroyData(_Data, newData); _Data = newData; if (OnTypeChanged != null) { OnTypeChanged.Invoke(this); } vPrevItemType = _ItemType; }
protected override void ImmediateReaction(ref Interactable publisher) { inventory.RemoveItem(item); OnItemLost.Invoke(item); }
protected override void ImmediateReaction(ref Interactable publisher) { inventory.AddItem(item); OnItemPickUp.Invoke(item); }
public void GiveItem(Item item) { _inventory.Add(item); AddedItemEvent.Invoke(item); }
public void RemoveItem(Item item) { _inventory.Remove(item); RemovedItemEvent.Invoke(item); }
private void OnUnSelectedSlot() { OnUnselect.Invoke(currentSlot.item); }
public virtual void UIClicked(ItemUI iui) { itemSelected.Invoke(iui.item); }
public virtual void AddItem(Item item) { items.Add(item); OnAddItem?.Invoke(item, this); }
public void OnEventRaised(Item value) { Response.Invoke(value); }