Potion Logic
Most of the potion logic for now
This commit is contained in:
61
3D blobici/Assets/Scripts/PotionsSkills/PotionHandler.cs
Normal file
61
3D blobici/Assets/Scripts/PotionsSkills/PotionHandler.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
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 PotionType potionType;
|
||||
|
||||
public enum PotionType
|
||||
{
|
||||
HealthSmall,
|
||||
HealthBig,
|
||||
Mana,
|
||||
None
|
||||
}
|
||||
|
||||
public PotionHandler()
|
||||
{
|
||||
foreach (PotionType type in System.Enum.GetValues(typeof(PotionType)))
|
||||
{
|
||||
potions.Add(type, 0);
|
||||
}
|
||||
|
||||
//textMeshProUGUI.text = potions[potionType].ToString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public bool UsePotion(PotionType type, int amount = 1)
|
||||
{
|
||||
potions[type] -= amount;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetAmount(PotionType type)
|
||||
{
|
||||
return potions[type];
|
||||
}
|
||||
|
||||
public bool IsEmpty(PotionType type)
|
||||
{
|
||||
return GetAmount(type) == 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e65daa0fc513fe4fa2efcaf544035ff
|
||||
Reference in New Issue
Block a user