public override void EnterHighlight() { GameObject selectedItem = InventoryItemController.GetSelectedItem(); // If we have a selected item, and we can equip, highlight green if (selectedItem && !isOccupied && CanEquip(selectedItem)) { image.color = SlotColorHighlights.Green; } // If we have a selected item and are occupied and can equip, highlight yellow else if (selectedItem && isOccupied && CanEquip(selectedItem)) { image.color = SlotColorHighlights.Yellow; } // else we have a selected item and cannot equip, highlight red else if (selectedItem && !CanEquip(selectedItem)) { image.color = SlotColorHighlights.Red; } else if (!selectedItem) { if (isOccupied) { image.color = SlotColorHighlights.Yellow; } else { image.color = initialColor; } } }
public void OnPointerClick(PointerEventData eventData) { Debug.Log("DING DING DING DING"); GameObject item = InventoryItemController.GetSelectedItem(); if (item) { // If an item is on the cursor and we drop it in the dropzone... item.GetComponent <InventoryItemController>().DropItem(inventoryOwner); } }
// Make highlighting virtual so we can override it if we need to like in Equips. public virtual void EnterHighlight() { // If we have a selected item, highlight if (InventoryItemController.GetSelectedItem() && !isOccupied) { image.color = SlotColorHighlights.Green; } else if (isOccupied) { image.color = SlotColorHighlights.Yellow; } }
public override void HandlePointerClick() { GameObject selectedItem = InventoryItemController.GetSelectedItem(); if (selectedItem == null || CanEquip(selectedItem)) { base.HandlePointerClick(); } else { Debug.Log("You can't do that you idiot"); } }
//Override this if there are different circumstances around handling trying to put an item into a slot public virtual void HandlePointerClick() { GameObject selectedItem = InventoryItemController.GetSelectedItem(); if (selectedItem != null) { if (isOccupied) { //If occupied, swap InventoryItemController.SetSelectedItem(SwapItem(selectedItem)); } else { //else, just store item StoreItem(selectedItem); InventoryItemController.ResetSelectedItem(); } } else if (selectedItem == null && isOccupied == true) { // If we are on a slot && don't have a selected item && there's an item present InventoryItemController.SetSelectedItem(GetItem()); } }