#pragma strict
var health:int;
var score: SpaceshipController;
var lives: SpaceshipController;
var otherObject: Collider;

function Start () {
	score = GameObject.FindGameObjectWithTag("Player").GetComponent(SpaceshipController);
	lives = GameObject.FindGameObjectWithTag("Player").GetComponent(SpaceshipController);
	MovementController.init(Camera.main.ScreenToWorldPoint(Vector3(0,Screen.height,0)).y,
							Camera.main.ScreenToWorldPoint(Vector3(0,0,0)).y,
							Camera.main.ScreenToWorldPoint(Vector3(0,0,0)).x,
							Camera.main.ScreenToWorldPoint(Vector3(Screen.width,0,0)).x);
	health = 10;
}

function Update () {

}

function OnTriggerEnter(otherObject:Collider)
{
	if (otherObject.gameObject.tag == "Player")
	{
		lives.lives = lives.lives - 1;
		GameObject.Destroy(this.gameObject);
		if (lives.lives == 0)
		{	
			Application.LoadLevel("GameOverScreen");
		}
	}
}

function DecreaseWingsHealth()
{
	health--;
	if(health == 0)
	{ 
		score.score = score.score + 10;
		Destroy(this.gameObject);
		Destroy(GameObject.FindGameObjectWithTag("Boss1TRight"));
		Destroy(GameObject.FindGameObjectWithTag("Boss1TLeft"));
	}
}