#pragma strict
var lives: SpaceshipController;
function Start () {
	lives = GameObject.FindGameObjectWithTag("Player").GetComponent(SpaceshipController);
}

function Update () {
	transform.Translate(Vector3.left * 15 * Time.deltaTime, Space.World);
	if (transform.position.x < MovementController.Leftmost())
	{
		GameObject.Destroy(this.gameObject);
	}
	if (transform.position.x > MovementController.Rightmost())
	{
		GameObject.Destroy(this.gameObject);
	}
	if (transform.position.y > MovementController.Topmost())
	{
		GameObject.Destroy(this.gameObject);
	}
	if (transform.position.y < MovementController.Bottommost())
	{
		GameObject.Destroy(this.gameObject);
	}
}

function OnTriggerEnter(otherObject:Collider)
{
	if (this.tag == "Bomb")
	{
		if (otherObject.gameObject.tag != "Boss1Mid" && otherObject.gameObject.tag != "Boss1TMid" && otherObject.gameObject.tag != "Boss2M" 
		 && otherObject.gameObject.tag != "Boss2R" && otherObject.gameObject.tag != "Boss2L" && otherObject.gameObject.tag == "Player")
		{
			lives.lives = lives.lives - 3;
			if (lives.lives <= 0)
			{	
				Application.LoadLevel("GameOverScreen");
			}	
		}
	}
}