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

public class InputManager : MonoBehaviour {

    public GameObject player1;
    public GameObject player2;
    public GameObject endHolder;
    //This list has all of the current players in the game
    public List<GameObject> players = new List<GameObject>();

    public string[] player1Inputs;
    public string[] player2Inputs;

    public GameObject player1WeaponObject;
    public GameObject player2WeaponObject;
    public RectTransform player1WeaponDisplay;
    public RectTransform player2WeaponDisplay;

    public GameObject player1Portrait;
    public GameObject player2Portrait;

    public GameObject player1HealthBar;
    public GameObject player2HealthBar;

    public static InputManager INPUTMANAGER;

    public int playerCount;
	// Use this for initialization
    //This also basically initializes the game
	void Start ()
    {
        
	    if(INPUTMANAGER == null)
        {
            if (PlayerAmount.PLAYERAMT != null)
            {
                playerCount = PlayerAmount.PLAYERAMT.playerAmount;
            }
            INPUTMANAGER = this;
            if(playerCount==1)
            {
                players.Add(player1);

                //TODO: Make it destroy all of P2 UI
                player1.GetComponent<PlayerDisease>().enabled = false;
                Destroy(player2);
                Destroy(player2HealthBar.gameObject);
                Destroy(player2WeaponObject.gameObject);
                Destroy(player2Portrait);
            }
            else
            {
                players.Add(player2);
                players.TrimExcess();
            }
        }
        else
        {
            Destroy(this);
        }
	}
	
	// Update is called once per frame
	void Update ()
    {
	    if(player1==null&&player2==null)
        {
            endHolder.SetActive(true);
            if(Input.GetButtonDown("Pause"))
            {
                SceneManager.LoadScene(0);
            }
        }
	}
}
