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

public class Trap : MonoBehaviour {

	public void OnTriggerEnter2D(Collider2D other)
	{	
		if (other.name != "Player")
			return;
		GameObject go = GameObject.Find ("Fade");
		Scene s = SceneManager.GetActiveScene ();
		((Fade)(go.GetComponent (typeof(Fade)))).setNext (s.name);
		((Fade)(go.GetComponent (typeof(Fade)))).setGagne (false);
		((Fade)(go.GetComponent(typeof(Fade)))).fadeIn();
		Destroy (other.gameObject);
	}

	public void OnCollisionEnter2D(Collision2D other){
		if (other.transform.name != "Player")
			return;
		GameObject go = GameObject.Find ("Fade");
		Scene s = SceneManager.GetActiveScene ();
		((Fade)(go.GetComponent (typeof(Fade)))).setNext (s.name);
		((Fade)(go.GetComponent (typeof(Fade)))).setGagne (false);
		((Fade)(go.GetComponent(typeof(Fade)))).fadeIn();
		Destroy (other.gameObject);
	}
}
