using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ACUIController : MonoBehaviour
{
    public RectTransform batteryBar;
    public UnityEngine.UI.Text batteryText;

    public UnityEngine.UI.Text summary;

    public int maxJoules;

    void Update()
    {
        var j = AC.instance.joules;
        batteryText.text = j + "kJ";
        batteryBar.anchorMax = new Vector2(
            Mathf.Min((float)j / maxJoules, 1),
            batteryBar.anchorMax.y);

        int sj = Mathf.CeilToInt(AC.instance.secondsRemaining);
        int mj = sj / 60;
        sj %= 60;

        int st = Mathf.CeilToInt(AC.instance.secondsUntilAnswer);
        int mt = st / 60;
        st %= 60;

        if (j > 0)
        {
            summary.text =
                "Time until Last Question Answered: " + mt + "m " + st + "s. Entropy used up in: " + mj + "m " + sj + "s.";
        }
        else
        {
            summary.text =
                "Last Question Calculations Halted. Local entropy at maximum.";
        }
    }
}
