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


public class Laser : MonoBehaviour {
	public int time = 300;
	int tic = 0;

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

	public void Activation()
	{	
		GetComponent<Renderer> ().enabled = false;
		GetComponent<Collider2D> ().enabled = false;
		tic = time;
	}

	public void Update(){
		if (tic != 0) {
			tic--;
			if (tic == 0) {
				GetComponent<Renderer> ().enabled = true;
				GetComponent<Collider2D> ().enabled = true;
			}
		}
	}
}
