Example #1
0
    //this will handle the UI event when an inventory item is selected, the item information will be displayed in the inventory grid, also sets the use or equip button for item interaction
    public void InventoryButtonEventHandler(int InventoryLocation)
    {
        informationGrid.transform.Find("ItemName").gameObject.GetComponent <Text>().text        = playerInventoryReference.getItemNameFromList(InventoryLocation);
        informationGrid.transform.Find("ItemAmount").gameObject.GetComponent <Text>().text      = playerInventoryReference.getInventoryItemAmount(InventoryLocation).ToString();
        informationGrid.transform.Find("ItemDescription").gameObject.GetComponent <Text>().text = playerInventoryReference.getItemDescription(InventoryLocation);
        informationGrid.transform.Find("ItemDescription").gameObject.GetComponent <Text>().text = playerInventoryReference.getItemDescription(InventoryLocation);
        informationGrid.transform.Find("AmountHeader").gameObject.GetComponent <Text>().enabled = true;
        currentlyViewedItemName = playerInventoryReference.getItemNameFromList(InventoryLocation);

        //setting the currentlyViewed prefab and enabling live preview

        if (currentlyViewed != null)
        {
            Destroy(currentlyViewed);
        }

        informationGrid.transform.Find("ItemView").gameObject.GetComponent <RawImage>().enabled = true;

        currentlyViewed = (GameObject)Instantiate(Resources.Load <GameObject>("InventoryItemSprites/" + playerInventoryReference.getItemNameFromList(InventoryLocation) + "View"), InventoryViewer.transform);

        //set child of InventoryView to the prefab View version of the Item in storage
        if (((currentlyEquipped == null) || !currentlyEquipped.GetComponent <WeaponsInterface>().getWeaponName().Equals(playerInventoryReference.getItemNameFromList(InventoryLocation))))
        {
            if (playerInventoryReference.getItem_Use_or_Equip_Type(InventoryLocation).Equals("Equip"))
            {
                DisplayEquipUIButton();
            }
            else
            {
                DisplayUseUIButton();
            }
        }
    }