using Assets.Scripts.Enums;
using System;
using System.Reflection;
using TMPro;
using UnityEngine;
namespace Assets.Scripts.Helpers
{
internal static class TextMeshProHelper
{
///
/// Will get the string value for a given enums value, this will
/// only work if you assign the StringValue attribute to
/// the items in your enum.
///
///
///
public static void UpdateItemMaxCountText(TextMeshProUGUI inventoryText, int itemCount, int maxCount)
{
float fillPercentage = (float)itemCount / maxCount * 100;
// Set color based on fill percentage
if (fillPercentage >= 100)
{
inventoryText.color = Color.red;
}
else if (fillPercentage >= 50)
{
inventoryText.color = Color.yellow;
}
else
{
inventoryText.color = Color.green;
}
inventoryText.text = $"{itemCount} ({maxCount})";
}
}
}