using UnityEngine;
using System.Collections;

public class ExitScript : MonoBehaviour {

	public int indexNextScene;
	public bool destroyPlayer;

	void Awake(){
		GameObject jogador = GameObject.FindGameObjectWithTag ("Player");
		jogador.transform.position = new Vector3(0, 0, -1);
	}

	void OnTriggerEnter2D(Collider2D col)
	{

		if (col.gameObject.tag == "Player") {
			if(destroyPlayer){
				Destroy(col.gameObject);
			}
			Application.LoadLevel (indexNextScene);
		}

	}

}
