#pragma strict

public var smoothBase : float;
var smoothNow : float = 0.0;
public var player : GameObject;

private var canMove : boolean = false;
private var over : boolean = false;

function GameOver (num : float) {
	Destroy(gameObject);
}

function Start () {

	gameObject.renderer.material.color.a = 0.9;

}

function Update () {

	//Debug.Log(over);
	if (player) {
		smoothNow = smoothBase + ((player.transform.position.y)*0.008f);
	}
	
	if (player && player.transform.position.y > 5 && !canMove) {
		canMove = true;
	}
	
	if (canMove) {
		transform.position.y += smoothNow * Time.deltaTime;
	}

	if (!player) {
		Death();
	}

}

function FixedUpdate () {

}

function Death () {
	renderer.material.SetColor("_Color", Color.red);
	Invoke("ChangeScene", 1);
}

function ChangeScene () {
	Application.LoadLevel("MainMenu");
}