Example #1
0
    //this will handle the UI event for using an item
    public void UseButtonEventHandler()
    {
        Debug.Log("Item Used");

        Debug.Log(currentlyViewedItemName);
        playerInventoryReference.useItem(playerInventoryReference.searchForItemName(currentlyViewedItemName));

        //Clause for a healing potion
        if (currentlyViewed.GetComponent <Potions_Interface>().getStatModified().Equals("HP"))
        {
            PlayerCharacter.GetComponent <CharacterStats>().healPlayerHP(currentlyViewed.GetComponent <Potions_Interface>().getPotionModiferAmount());
        }
        //add different types of potions here



        Debug.Log("Changing inventory amount");
        informationGrid.transform.Find("ItemAmount").gameObject.GetComponent <Text>().text = playerInventoryReference.getInventoryItemAmount(playerInventoryReference.searchForItemName(currentlyViewedItemName)).ToString();
        PlayerCharacter.GetComponent <CharacterStats>().updateUIHPGauge();

        if (playerInventoryReference.getInventoryItemAmount(playerInventoryReference.searchForItemName(currentlyViewedItemName)) == 0)
        {
            informationGrid.transform.Find("UseButton").gameObject.GetComponent <Button>().interactable = false;
        }
        else
        {
            informationGrid.transform.Find("UseButton").gameObject.GetComponent <Button>().interactable = true;
        }
    }