35 lines
758 B
C#
35 lines
758 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class BoostCapacityUI : MonoBehaviour
|
|
{
|
|
[SerializeField] private Color goodColor = new Color(138, 81, 86, 100);
|
|
[SerializeField] private Color criticalColor = new Color(358, 88, 93, 100);
|
|
private Image fillImage;
|
|
private float minBoostRatio = 0.3f;
|
|
// Start is called before the first frame update
|
|
void Awake()
|
|
{
|
|
// TODO Crude
|
|
fillImage = gameObject.GetComponentsInChildren<Image>()[1];
|
|
}
|
|
|
|
public void SetMinBoostRatio(float minBoostRatio)
|
|
{
|
|
this.minBoostRatio = minBoostRatio;
|
|
}
|
|
|
|
public void UpdateFill(float fill)
|
|
{
|
|
fillImage.fillAmount = fill;
|
|
if (fillImage.fillAmount <= minBoostRatio)
|
|
{
|
|
fillImage.color = criticalColor;
|
|
}
|
|
else
|
|
{
|
|
fillImage.color = goodColor;
|
|
}
|
|
}
|
|
}
|