using UnityEngine;
using System.Collections;

public class SpelunkerVsEnemy : MonoBehaviour
{
		public GameObject explosion;
		public GameObject gameOver;

		void OnTriggerEnter2D (Collider2D other)
		{
				if (other.gameObject.tag == "Mine" || other.gameObject.tag == "Rocket") {
						GameObject e = (GameObject)Instantiate (explosion, other.transform.position, Quaternion.identity);
						Destroy (e, 0.5f);
						
						e = (GameObject)Instantiate (explosion, transform.position, Quaternion.identity);
						Destroy (e, 0.5f);
						
						Destroy (other.gameObject);
						
						Lives.lives--;
						
						transform.parent.position = new Vector2 (0, 10);
						
						if (Lives.lives < 1) {
								gameOver.guiText.enabled = true;
								Destroy (transform.parent.gameObject);
								Time.timeScale = 0;
						}
				}
		}
}
