using TMPro;
using UnityEngine;
using UnityEngine.UI;
///
/// HUD element which displays a ships remaining boost capacity.
///
public class BoostCapacityUI : MonoBehaviour
{
public Color goodColor = Color.green;
public Color criticalColor = Color.red;
[SerializeField] private int playerNumber = 0;
[SerializeField] private Image fillImage;
[SerializeField] private TextMeshProUGUI hint;
private float minBoostRatio = 0.3f;
///
/// Ratio of capacity to max capacity under which the
/// boost capacity is considered critically low.
///
///
public void SetMinBoostRatio(float minBoostRatio)
{
this.minBoostRatio = minBoostRatio;
}
public void SetPlayerName(Player p)
{
hint.SetText($"Boost Capacity \n {p.playerName} \n {p.character.shipName}");
}
///
/// Updates the color and fill of the capacity meter.
///
/// Fill percentage
public void UpdateFill(float fill)
{
fillImage.fillAmount = fill;
if (fillImage.fillAmount <= minBoostRatio)
{
fillImage.color = criticalColor;
}
else
{
fillImage.color = goodColor;
}
}
}