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

public class Door : MonoBehaviour {

    public Transform TargetDoor;
    public bool isWorking = false;

    private void OnTriggerEnter2D(Collider2D collision)
    {


		if ((collision.tag.Equals("Player") || collision.tag.Equals("Agent")) && isWorking)
        {



			TargetDoor.GetComponent<Door>().isWorking = false;
            TargetDoor.GetComponent<BoxCollider2D>().enabled = true;
			collision.transform.position = TargetDoor.position;



        }



    }

    private void OnTriggerExit2D(Collider2D collision)
    {
		if (collision.tag.Equals("Player") || collision.tag.Equals("Agent"))
        {
            isWorking = true;
        }
    }
}
