using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FillController : MonoBehaviour
{
    public Image Player1Bar, Player2Bar;
    // Use this for initialization
    void Start()
    {
        Player1Bar = GameObject.FindGameObjectWithTag("Player1Bar").GetComponent<Image>();
        Player2Bar = GameObject.FindGameObjectWithTag("Player2Bar").GetComponent<Image>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (GameController.P1IdleMania)
        {
            Player1Bar.enabled = true;
            Player1Bar.fillAmount -= 1.0f / 6f * Time.deltaTime;
        }
        else if (GameController.P2IdleMania)
        {
            Player2Bar.enabled = true;
            Player2Bar.fillAmount -= 1.0f / 6f * Time.deltaTime;
        }
        if (!GameController.P1IdleMania)
        {
            Player1Bar.enabled = false;
        }
        else if (!GameController.P2IdleMania)
        {
            Player2Bar.enabled = false;
        }

        if (Player1Bar.fillAmount == 0)
        {
            Player1Bar.fillAmount = 1;
        }
        if (Player2Bar.fillAmount == 0)
        {
            Player2Bar.fillAmount = 1;
        }

    }
}
