public void ItemSlotButtonClick(ItemSlot itemSlot) { Debug.Log("Implemented button clicked"); if (itemSlot.CompareTag("MarketplaceItemSlot")) { GameObject marketItem = itemSlot.heldItem; GameObject[] storageItemsSlots = GameObject.FindGameObjectsWithTag("PlayerItemSlot"); for (int i = 0; i < storageItemsSlots.Length; i++) { Debug.Log(storageItemsSlots[i].GetComponent <ItemSlot>().heldItem); if (storageItemsSlots[i].GetComponent <ItemSlot>().heldItem == marketItem) { Debug.Log("Found match with: " + storageItemsSlots[i].GetComponent <ItemSlot>().heldItem); storageItemsSlots[i].GetComponent <ItemSlot>().DropItem(); playerMoney.AddPlayerMoney(marketItem.GetComponent <Item>().GetPrice()); itemSlot.gameObject.SetActive(false); return; } else { Debug.Log("No match found for " + marketItem + "your item was: " + storageItemsSlots[i].GetComponent <ItemSlot>().heldItem); } } return; } if (activeItemTransfer == false) { if (itemSlot.GetItem() != null) { //No item transfer is active - initiate a new one. activeItemTransfer = true; Cursor.SetCursor(cursorTexture, hotSpot, cursorMode); activeItemSlot = itemSlot; itemInTransfer = itemSlot.GetItem(); itemSlot.SpriteFade(); Debug.Log("Held item is: " + itemInTransfer); } else { DisplayHelpTextMessage("No item exists in item slot"); Debug.Log("No item exists in item slot"); } } else if (activeItemTransfer == true) { //Check if clicked itemslot destination is empty if (itemSlot.GetItem() == null) { Debug.Log("Transfer allowed...now checking if purchase is made."); //Check if basic transfer or transfer between seller and player. if (itemSlot.CompareTag("PlayerItemSlot")) { //Player item slot clicked, check if active itemslot is sellers //if so, transaction is made. if (activeItemSlot.CompareTag("SellerItemSlot")) { int cost = activeItemSlot.heldItem.GetComponent <Item>().GetPrice(); //Check if affordable if (playerMoney.GetMoney() >= cost) { playerMoney.RemovePlayerMoney(cost); TransferItem(itemSlot); DisplayHelpTextMessage("You bought " + itemSlot.heldItem.GetComponent <Item>().GetName()); if (transitionManager != null) { transitionManager.SetContinueButtonVisible(); } } else { DisplayHelpTextMessage("Cannot afford purchase"); Debug.Log("Cannot afford purchase"); } } else { if (itemSlot.isFridge == false && activeItemSlot.heldItem.GetComponent <Item>().isFoodItem == true) { Debug.Log("NONONO!"); } else { TransferItem(itemSlot); } } } else if (itemSlot.CompareTag("SellerItemSlot")) { //Seller item slot clicked, check if active itemslot is players //if so, transfer is illegal. if (activeItemSlot.CompareTag("PlayerItemSlot")) { Debug.Log("item transfer illegal!"); DisplayHelpTextMessage("You are not allowed to sell items right now!"); } else { TransferItem(itemSlot); } } else { Debug.Log("Error! Could not find recognizable tag for item slot."); } } else if (itemSlot == activeItemSlot) { Debug.Log("Same itemslot clicked, now deactivating transfer"); activeItemTransfer = false; Cursor.SetCursor(null, Vector2.zero, cursorMode); activeItemSlot.UpdateItemImage(); } else { Debug.Log("An item already exists in this slot"); DisplayHelpTextMessage("An item already exists in this slot."); } } }