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

public class ReloadPlayers : MonoBehaviour
{
    public GameObject playerOrange;
    public GameObject playerBlue;
    public Animator doorAnimator;
    public PlayerInput playerInput;

    public Vector3 orangePlayerPosition;
    public Vector3 bluePlayerPosition;

    private Button button;
    private InputActionMap currentActionMap;

    private void Awake()
    {
        button = GetComponent<Button>();
        currentActionMap = playerInput.currentActionMap;
    }

    void Start()
    {
        currentActionMap.FindAction("Restart").started += _ => button.onClick.Invoke();
    }


    public void LoadPlayers()
    {
        doorAnimator.SetBool("DoorOpen", false);

        playerOrange.transform.position = orangePlayerPosition;
        playerBlue.transform.position = bluePlayerPosition;

        playerBlue.SetActive(true);
        playerOrange.SetActive(true);
    }
}
