public bool DropItem() { Debug.Log("Attempting to drop"); if (selectedSlot.Count > 0) { // Do not allow player to drop their shovel if (selectedSlot.First.Value != null && selectedSlot.First.Value.itemName == "Shovel") { return(false); } Item2 droppedItem = selectedSlot.First.Value; droppedItem.GetComponent <SpriteRenderer>().enabled = true; //droppedItem.transform.position = gameObject.transform.position; Done in command script selectedSlot.Remove(droppedItem); if (selectedSlot.Count == 0) { Image image = selectedSlotUI.transform.GetChild(0).GetComponent <Image>(); // For shorter reference image.color = new Color(image.color.r, image.color.g, image.color.b, 0f); // Remove visibility of item icon by setting alpha to 0 selectedSlotUI.transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = ""; // clear text } else { selectedSlotUI.transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "x " + itemSlots[selectedSlotNumber].Count; } return(true); } return(false); }
public void ItensEnable() { Item1.GetComponent <BoxCollider2D> ().enabled = true; Item2.GetComponent <BoxCollider2D> ().enabled = true; Item3.GetComponent <BoxCollider2D> ().enabled = true; Item4.GetComponent <BoxCollider2D> ().enabled = true; Item5.GetComponent <BoxCollider2D> ().enabled = true; Item6.GetComponent <BoxCollider2D> ().enabled = true; }
//Called by sell bin on player click when in range public void SellItem() { Item2 item = selectedSlot.First.Value; //Sellables work differently if (item.itemName.Length > 8 && item.itemName.Substring(0, 8) == "Sellable") { Sellable sellComp = item.GetComponent <Sellable>(); if (sellComp.SellPlant()) { SoundControl.PlayMoneySound(); ItemUsed(); } } }