#pragma strict

var speed:int;
var mainController:MainController;

function Start ()
{
	mainController = GameObject.FindGameObjectWithTag("MainCamera").GetComponent("MainController");
	
	if (mainController.level == 1)
		speed = 800;
	else if (mainController.level == 2)
		speed = 850;
	else
		speed = 900;
	
	rigidbody.AddForce(Vector3.left * speed, ForceMode.Force);
}

function OnBecameInvisible()
{
	mainController.score += 2;
	Destroy(this.gameObject);
}

function OnCollisionEnter(otherObject:Collision)
{
	if (otherObject.gameObject.tag.Equals("Floor"))
		renderer.material = mainController.materials[Random.Range(0,4)];
}