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

public class UIManager : MonoBehaviour {

    public Image HPBar;
    public Text energy;
    public Text victory;
    public Text gameOver;
    public Button menu;

    private static UIManager _instance;

    public static UIManager Instance {
        get {
            if (_instance == null) {
                _instance = FindObjectOfType<UIManager>();
            }
            return _instance;
        }
    }

    private void Update () {
        float normalizedHP = (float)GameManager.Instance.player.health / GameManager.Instance.player.maxHealth;
        HPBar.GetComponent<RectTransform>().sizeDelta = new Vector2(Mathf.Lerp(0, 235f, normalizedHP), 45f);
        HPBar.color = Color.Lerp(Color.red, Color.green, normalizedHP);
        energy.text = GameManager.Instance.GetCurrentEnergy() + "/" + GameManager.Instance.GetGoalEnergy();
    }

    public void DisplayVictory () {
        victory.gameObject.SetActive(true);
    }

    public void DisplayGameOver () {
        gameOver.gameObject.SetActive(true);
    }

    public void DisplayMenu () {
        menu.gameObject.SetActive(true);
    }

}
