public void AddItem(ItemInSlot newItemInSlot) { countOfObject = newItemInSlot.numberOfItem; itemInSlot = newItemInSlot; icon.sprite = itemInSlot.item.icon; countText.text = countOfObject.ToString(); SetUIActive(true); }
/// <summary> /// Activate the item currently held in the slot /// </summary> public void UseItem() { if (ItemInSlot != null) { if (ItemCount >= 1) { ItemInSlot.Use(); onItemUse.Invoke(ItemInSlot); ItemCount--; b_needsUpdate = true; } } }
/// <summary> /// Activate the item currently held in the slot /// </summary> // Temporarily removed since it uses left-click public void UseItem(GameObject character) { if (ItemInSlot != null) { if (ItemCount >= 1) { ItemInSlot.Use(character); onItemUse.Invoke(ItemInSlot); ItemCount--; b_needsUpdate = true; } } }
public void RemoveItem(ItemInSlot itemSlot) { if (itemSlot.numberOfItem == 1) { items.Remove(itemSlot); } else { itemSlot.numberOfItem -= 1; } if (onItemChangedCallBack != null) { onItemChangedCallBack.Invoke(); } }
/// <summary> /// Activate the item currently held in the slot /// </summary> public void UseItem() ///Where Magic Happens. { if (ItemInSlot == null) { //Debug.Log("Here"); if (!outputslot) // If its Not an Output Slot Then do this. { if (PlayerCharacter.GetComponent <GrabnGo>().grabbed == true) // Are we Grabbing any thing? { SetContents(PlayerCharacter.GetComponent <Inventory>().masterItemTable.GetItem(PlayerCharacter.GetComponent <GrabnGo>().item), 1); //Then Set THe contents. PlayerCharacter.GetComponent <GrabnGo>().grabbed = false; //Now that we have set Everything We turn that to False. Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); // Setting our Cursor to Nothing. ItemCount = 1; b_needsUpdate = true; if (PlayerCharacter.GetComponent <GrabnGo>().grabbedOutput) // Are We grabbing output? { GameObject[] gameObject = GameObject.FindGameObjectsWithTag("ItemSlotCrafting"); // Lets go the Crafting Table. foreach (var item in gameObject) { item.SendMessage("ClearSlot"); } PlayerCharacter.GetComponent <GrabnGo>().grabbedOutput = false; } craftingTraversal(); //Run this Method. return; } } } if (ItemInSlot != null) { if (ItemCount >= 1) { Debug.Log("CraftHere"); ItemInSlot.Use(); // First er use the Item. onItemUse.Invoke(ItemInSlot); //Invoke On ITem Use. ItemCount--; b_needsUpdate = true; } } }
public bool AddItem(Item item) { if (item.isDefaultItem) { return(false); } for (int i = 0; i < items.Count; i++) { ItemInSlot itemSlot = items[i]; bool willAddToStack = item.isStackable && itemSlot.item.Equals(item) && itemSlot.numberOfItem < stackSize; if (willAddToStack) { itemSlot.numberOfItem++; if (onItemChangedCallBack != null) { onItemChangedCallBack.Invoke(); } return(true); } } if (items.Count >= inventorySize) { return(false); } AddToFirstEmptySlot(item); if (onItemChangedCallBack != null) { onItemChangedCallBack.Invoke(); } return(true); }
private void AddToFirstEmptySlot(Item item) { ItemInSlot _itemSlot = new ItemInSlot(item, 1); items.Add(_itemSlot); }
public void ClearSlot() { itemInSlot = null; icon.sprite = null; SetUIActive(false); }