using UnityEngine;
using System.Collections;

public class DestroyByContact : MonoBehaviour
{
	public GameObject explosion;
	public GameObject playerExplosion;
	void OnCollisionEnter2D(Collision2D other)
	{
		if (other.gameObject.tag == "Boundary")
		{
			return;
		}

		if (explosion != null)
		{
			Instantiate(explosion, other.transform.position, Quaternion.identity);
		}

		Destroy(other.gameObject);

		if(other.gameObject.tag == "Player")
		{
			Invoke("Reload", 3f);
		}
	}

	void Reload()
	{
		Application.LoadLevel("main_gameplay");
	}
	void OnTriggerEnter (Collider other)
	{
		/*if (other.tag == "Boundary" || other.tag == "Enemy")
		{
			return;
		}

		if (explosion != null)
		{
			Instantiate(explosion, transform.position, transform.rotation);
		}*/

		/*if (other.tag == "Player")
		{
			Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
		}*/
		
		//Destroy (other.gameObject);
		//Destroy (gameObject);
	}
}