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

public class ComputerScript : MonoBehaviour {

    public enum ComputerColor
    {
        orange, green, blue
    };
    public ComputerColor computerColor;
    [SerializeField]private GameObject doorToOpen;
    [SerializeField] private GameObject keyPrompt;
    private void OnTriggerStay2D(Collider2D collision)
    {
        ScientistScript colScript = collision.gameObject.GetComponent<ScientistScript>();

        if(collision.isTrigger)
            return;

        if(colScript != null)
        {
            keyPrompt.SetActive(true);
            if ((int)colScript.scientistColor == (int)computerColor)
            {                
                keyPrompt.GetComponent<Animator>().SetBool("Enabled",true);
                if (Input.GetKeyDown(KeyCode.E))
                {
                    doorToOpen.GetComponent<DoorScript>().OpenDoor();
                }
            }
            else
            {
                keyPrompt.GetComponent<Animator>().SetBool("Enabled", false);
            }

        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        keyPrompt.SetActive(false);
    }
}
