/// <summary> /// Remove desired item of the target <seealso cref="vItemManager"/> /// </summary> public void RemoveDesiredItem() { if (itemManager) { if (getItemByName) { if (ContainsItem(itemManager)) { itemManager.DestroyItem(itemManager.GetItem(itemName), desiredAmount > 1 ? desiredAmount : 1); } } else { if (ContainsItem(itemManager)) { itemManager.DestroyItem(itemManager.GetItem(itemID), desiredAmount > 1 ? desiredAmount : 1); } } } }
protected virtual void CheckItem(vItemManager itemManager) { if (getItemByName) { // VERIFY IF YOU HAVE A SPECIFIC ITEM IN YOUR INVENTORY if (itemManager.ContainItem(itemName)) { // AUTOMATICALLY EQUIP THE ITEM IF YOU HAVE IT // // - vItem can be access using the itemManager.GetItem(itemName) // - indexArea is the equipmentArea that you want to equip the item, for example 0 is RightArm, 1 is LeftArm, 2 is Consumable. // - Immediate is true to instantly equip the weapon or false to trigger the equip animation. itemManager.AutoEquipItem(itemManager.GetItem(itemName), 0, false); // trigger OnContains Event onContains.Invoke(); } else { onNotContains.Invoke(); } } else { // VERIFY IF YOU HAVE A SPECIFIC ITEM IN YOUR INVENTORY if (itemManager.ContainItem(itemID)) { // AUTOMATICALLY EQUIP THE ITEM IF YOU HAVE IT // // - vItem can be access using the itemManager.GetItem(itemName) // - indexArea is the equipmentArea that you want to equip the item, for example 0 is RightArm, 1 is LeftArm, 2 is Consumable. // - Immediate is true to instantly equip the weapon or false to trigger the equip animation. itemManager.AutoEquipItem(itemManager.GetItem(itemID), 0, false); // trigger OnContains Event onContains.Invoke(); } else { onNotContains.Invoke(); } } }
vItem GetItem(vItemManager itemManager) { if (getItemByName) { // VERIFY IF YOU HAVE A SPECIFIC ITEM IN YOUR INVENTORY if (itemManager.ContainItem(itemName)) { return(itemManager.GetItem(itemName)); } } else { // VERIFY IF YOU HAVE A SPECIFIC ITEM IN YOUR INVENTORY if (itemManager.ContainItem(itemID)) { return(itemManager.GetItem(itemID)); } } return(null); }
vItem GetItem(vItemManager itemManager) { if (getItemByName) { // Check if you have an item via name (string) in your Inventory if (itemManager.ContainItem(itemName)) { return(itemManager.GetItem(itemName)); } } else { // Check if you have an item via ID (integer) in your Inventory if (itemManager.ContainItem(itemID)) { return(itemManager.GetItem(itemID)); } } return(null); }
public void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { itemManager = other.GetComponent <vItemManager>(); if (itemManager) { itemEvent.targetItem = itemManager.GetItem(itemEvent.id); if (itemEvent.targetItem) { itemEvent.ChangeItemUsageDelay(); itemManager.onUseItem.AddListener(OnUseItem); itemManager.onOpenCloseInventory.AddListener(itemEvent.OnOpenInventory); itemEvent.targetItem.canBeUsed = true; } } } }