using UnityEngine;

public class MainDoor : MonoBehaviour 
{
    public Sprite OpenDoor;
    public Transform GoalTrigger;
    public float DelayTime = 1f;

    private bool open = false;
	
    void Start()
    {
        GoalTrigger.gameObject.SetActive(false);
    }

	void Update () 
	{
        if(!open && MustKill.EnemiesAlive == 0)
        {
            Invoke("OpenTheDoor", DelayTime);
        }
    }

    private void OpenTheDoor()
    {
        GetComponent<SpriteRenderer>().sprite = OpenDoor;
        GoalTrigger.gameObject.SetActive(true);
        open = true;
    }
}
