#pragma strict
var movementspeed: float;
var buffer: float;
static var score: int;
static var lives: int;
//var SpaceShip: Rigidbody[] = new Rigidbody[1];

function Start () {
	//var RandomSpaceShipSelect : int = Random.Range(0,SpaceShip.Length); //randomize spaceship
	//var	RandomSpaceShip: Rigidbody = SpaceShip[RandomSpaceShipSelect]; //put random spaceship here
	
	//Instantiate(RandomSpaceShip, Vector3(-11.9,0,5), Quaternion.identity);
	
	lives = 3;
	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);
}

function Update () {
	if (Input.GetKeyDown(KeyCode.Space))
	{
		Instantiate(MovementController.Friendlylaser(), transform.position, transform.rotation);
	}
	
	transform.Translate(Vector3.right * Input.GetAxis("Vertical") * movementspeed * Time.deltaTime);
	transform.Translate(Vector3.down * Input.GetAxis("Horizontal") * movementspeed * Time.deltaTime);
	
	if (transform.position.x < MovementController.Leftmost() + buffer)
	{
		transform.position.x = MovementController.Leftmost() + buffer;
	}
	if (transform.position.x > MovementController.Rightmost() - buffer)
	{
		transform.position.x = MovementController.Rightmost() - buffer;
	}
	if (transform.position.y > MovementController.Topmost() - buffer)
	{
		transform.position.y = MovementController.Topmost() - buffer;
	}
	if (transform.position.y < MovementController.Bottommost() + buffer)
	{
		transform.position.y = MovementController.Bottommost() + buffer;
	}
}


function OnGUI()
{
	GUI.Label(Rect(10,10,100,100), "Score: " + score);
	GUI.Label(Rect(10,30,100,100), "Lives: " + lives);
}