Beispiel #1
0
 // ----------------------------Consumable---------------------------
 void UseConsumbale()
 {
     if (playerConsumable.GetItemList()[selectedConsumable].amount > 0)
     {
         if (playerConsumable.GetItemList()[selectedConsumable].type.ToString() == "fortunePouch")
         {
             Instantiate(healParticle, transform.position, transform.rotation);
             gameObject.GetComponent <PlayerStat>().SendMessage("increaseHP", (playerConsumable.GetItemList()[selectedConsumable] as fortunePouch).Heal());
         }
         else if (playerConsumable.GetItemList()[selectedConsumable].type.ToString() == ("crimsonAsh"))
         {
             //Make player can not be hurt by anything
             StartCoroutine(useCrimsonAsh());
         }
         else if (playerConsumable.GetItemList()[selectedConsumable].type.ToString() == ("homingAsh"))
         {
             //Teleport player
             transform.position = gameObject.GetComponent <PlayerStat>().checkpointPosition;
         }
         playerConsumable.GetItemList()[selectedConsumable].decreaseAmount();
     }
     else
     {
         Debug.Log("No more " + playerConsumable.GetItemList()[selectedConsumable].type + " to use");
     }
 }
    public void RefreshConsumableInventory()
    {
        int i = 0;

        foreach (Transform item in transform)
        {
            if (i == 0)
            {
            }
            else
            {
                Destroy(item.gameObject);
            }
            i++;
        }
        foreach (Item item in playerConsumable.GetItemList())
        {
            RectTransform consumableSlot = Instantiate(ConsumableSlotTemplate, transform).GetComponent <RectTransform>();
            consumableSlot.gameObject.SetActive(true);
            Image image = consumableSlot.Find("Item").GetComponent <Image>();
            image.sprite = item.GetSprite();
            try
            {
                if (consumableSlot.Find("TextPro").GetComponent <TextMeshProUGUI>() != null)
                {
                }
                consumableSlot.Find("TextPro").GetComponent <TextMeshProUGUI>().text = item.max.ToString();
            }
            catch
            {
                Debug.Log("Text not found");
            }
        }
    }
Beispiel #3
0
 // ----------------------------Consumable---------------------------
 void UseConsumbale()
 {
     if (playerConsumable.GetItemList()[selectedConsumable].amount > 0)
     {
         if (playerConsumable.GetItemList()[selectedConsumable].type.ToString() == "fortunePouch")
         {
             gameObject.GetComponent <PlayerStat>().SendMessage("increaseHP", (playerConsumable.GetItemList()[selectedConsumable] as fortunePouch).Heal());
         }
         else if (playerConsumable.GetItemList()[selectedConsumable].type.ToString() == ("crimsonAsh"))
         {
             StartCoroutine(useCrimsonAsh());
         }
         else if (playerConsumable.GetItemList()[selectedConsumable].type.ToString() == ("homingAsh"))
         {
             Debug.Log("Using homing ash");
         }
         playerConsumable.GetItemList()[selectedConsumable].decreaseAmount();
     }
     else
     {
         Debug.Log("No more " + playerConsumable.GetItemList()[selectedConsumable].type + " to use");
     }
 }