using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class InventoryItemController : MonoBehaviour { public GameObject Player; public PlayerController playerController; //public List Items = new List(); Item item; [Header("UI")] public TextMeshProUGUI countText; public int count; public Button RemoveButton; void Start() { Player = GameObject.FindWithTag("Player"); playerController = Player.GetComponent(); //RefreshCount(); countText.text = count.ToString(); } public void RemoveItem() { InventoryManager.Instance.Remove(item); Destroy(gameObject); //RefreshCount(); } public void AddItem(Item newItem) { item = newItem; //Update(); IncrementCounter(); // RefreshCount(); } public int IncrementCounter() { count = count +1; Debug.Log("count value is " + count); return count; } public void UseItem() { switch (item.itemType) { case Item.ItemType.Potion: playerController.IncreaseHealth(item.value); Debug.Log("using item"); break; case Item.ItemType.Other: Debug.Log("using item2"); playerController.IncreaseExp(item.value); break; default: break; } RemoveItem(); //RefreshCount(); } public void RefreshCount() { //countText.text = $"{count}"; //Debug.Log("number is " + count); //countText.text = count.ToString(); bool textActive = count > 0; countText.gameObject.SetActive(textActive); //Debug.Log("stacked items: " +count); } //private void Update() //{ // RefreshCount(); //} }