PotionGui
This commit is contained in:
@@ -7,7 +7,7 @@ public class PotionHandler:MonoBehaviour
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
|
||||
private Dictionary<PotionType, int> potions = new Dictionary<PotionType, int>();
|
||||
[SerializeField] private TextMeshProUGUI textMeshProUGUI;
|
||||
[SerializeField] private TMP_Text textMeshProUGUI;
|
||||
[SerializeField] private PotionType potionType;
|
||||
|
||||
public enum PotionType
|
||||
@@ -18,34 +18,40 @@ public class PotionHandler:MonoBehaviour
|
||||
None
|
||||
}
|
||||
|
||||
public PotionHandler()
|
||||
private void Awake()
|
||||
{
|
||||
foreach (PotionType type in System.Enum.GetValues(typeof(PotionType)))
|
||||
{
|
||||
potions.Add(type, 0);
|
||||
}
|
||||
|
||||
//textMeshProUGUI.text = potions[potionType].ToString();
|
||||
textMeshProUGUI.text = potions[potionType].ToString();
|
||||
|
||||
// Register this handler with the PlayerSkillTree
|
||||
PlayerSkillTree.Instance.RegisterPotionHandler(potionType, this);
|
||||
}
|
||||
|
||||
|
||||
public void AddPotion(PotionType type, int amount = 1)
|
||||
{
|
||||
potions[type] += amount;
|
||||
Debug.Log(potions[type]);
|
||||
|
||||
if(type == potionType)
|
||||
{
|
||||
textMeshProUGUI.text= potions[type].ToString();
|
||||
}
|
||||
|
||||
//Debug.Log("Text is: " + textMeshProUGUI.text);
|
||||
Debug.Log("Potion text is: " + textMeshProUGUI.text);
|
||||
}
|
||||
|
||||
public bool UsePotion(PotionType type, int amount = 1)
|
||||
{
|
||||
potions[type] -= amount;
|
||||
|
||||
if (type == potionType)
|
||||
{
|
||||
textMeshProUGUI.text = potions[type].ToString();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user