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

public class ManageTraps : MonoBehaviour
{
    public GameObject otherPlayer;
    public GameObject canvas;
    public GameObject gameOverlay;

    private IEnumerator coroutine;


    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Trap")
        {
            coroutine = waitForAnim();
            StartCoroutine(coroutine);
        }
    }

    private IEnumerator waitForAnim()
    {
        gameObject.GetComponent<Animator>().SetBool("isDead", true);
        yield return new WaitForSeconds(0.45f);
        canvas.SetActive(true);
        gameOverlay.SetActive(true);
        otherPlayer.SetActive(false);
        gameObject.SetActive(false);
    }
}
