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

namespace Prisma.Main
{
    public class Elevator : MonoBehaviour
    {
        [SerializeField]
        private GameObject door;
        [SerializeField]
        private GameObject mng; 

        private void OnTriggerEnter2D(Collider2D col)
        {
            if (col.gameObject.name == "Thief")
            {
                StartCoroutine(NextLevel());
            }
        }
      
        private IEnumerator NextLevel()
        {
            door.GetComponent<Animator>().SetTrigger("Close");
            door.GetComponent<AudioSource>().Play();
            yield return new WaitForSeconds(0.5f);
            this.GetComponent<AudioSource>().Play();
            this.GetComponent<Animator>().SetTrigger("Up");
        }

        public void ElevTop()
        {
            mng.GetComponent<GameMngr>().LevelUp();
        }

    }
}