using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.UI;
public class InDoor : MonoBehaviour
{

public GameObject InDoorPanel;

private void Start()
{
    InDoorPanel.GetComponent<Image>().color = new Color(InDoorPanel.GetComponent<Image>().color.r, 
        InDoorPanel.GetComponent<Image>().color.g, InDoorPanel.GetComponent<Image>().color.b, 0);
    InDoorPanel.transform.position = new Vector3(InDoorPanel.transform.position.x,
        -100, InDoorPanel.transform.position.z);
    //InDoorPanel.transform.localScale= Vector3.zero;
    InDoorPanel.SetActive(false);
}

private void OnTriggerEnter2D(Collider2D collision)
{
    if (collision.tag == "Player")
    {
        InDoorPanel.SetActive(true);
        InDoorPanel.GetComponent<Image>().DOColor(new Color(InDoorPanel.GetComponent<Image>().color.r, 
            InDoorPanel.GetComponent<Image>().color.g, InDoorPanel.GetComponent<Image>().color.b, 0.7f), 0.3f);
        InDoorPanel.transform.DOMoveY(110, 0.3f);
        //InDoorPanel.transform.DOScale(Vector3.one, 0.3f);
    }
}

private void OnTriggerExit2D(Collider2D collision)
{
    if (collision.tag == "Player")
    {
        InDoorPanel.GetComponent<Image>().DOColor(new Color(InDoorPanel.GetComponent<Image>().color.r, 
            InDoorPanel.GetComponent<Image>().color.g, InDoorPanel.GetComponent<Image>().color.b, 0), 0.3f);
        InDoorPanel.transform.DOMoveY(-100, 0.3f).OnComplete(() => InDoorPanel.SetActive(false));
        //InDoorPanel.transform.DOScale(Vector3.zero, 0.3f);
    }
}

}