
//THIS SCRIPT CALCULATES THE TIME LEFT BEFORE THE GAME ENDS AND SENDS IT TO THE GUITEXT. WHEN THE TIME 
//ENDS IT CALCULATES WHETHER THE PLAYER WON OR LOST AND LOADS THE ENDSCENE

static var startTime:float;
static var timeRemaining:float;
var minutes:int;
var seconds:int;
var timeStr:String;
static var playerHasLost:boolean=true;



function Start()
{
	startTime=10.0; //in seconds
}

function Update () 
{
	timeRemaining=startTime-Time.timeSinceLevelLoad;
	minutes=timeRemaining/60;
	seconds=timeRemaining%60;
	timeStr=minutes.ToString() + ":";
	timeStr+=seconds.ToString("D2");
	guiText.text=timeStr;
	
	
	if (timeRemaining<0)
	{
		if(scoreScript4.score>=1)
			playerHasLost=false;
		
		Application.LoadLevel ("EndScene");
	}
}