Hello, I’m 15 years old Mono-Developer from Turkey. I’m workng on Duck Shoot Project for begining but i have some issues.
There’s a code that i found from web for “Countdown”
pragma strict
///////////////////////////////////////////////////////////
var startTime : float;
var restSeconds : float;
var roundedRestSeconds : int;
var displaySeconds : float;
var displayMinutes : float;
var timeLeft : float;
static var countDownSeconds : int = 15;
var timeText : String;
///////////////////////////////////////////////////////////
function Start()
{
startTime = Time.deltaTime;
}
///////////////////////////////////////////////////////////
function OnGUI ()
{
timeLeft = Time.time - startTime;
restSeconds = countDownSeconds - (timeLeft);
roundedRestSeconds = Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = (roundedRestSeconds / 60) %60;
timeText = (displayMinutes.ToString() + ":");
///////////////////////////////////////////////////////////
if (displaySeconds > 9)
{
timeText = timeText + displaySeconds.ToString();
}
else
{
timeText = timeText + "0" + displaySeconds.ToString();
}
var textMesh : TextMesh = gameObject.GetComponent(TextMesh);
textMesh.text = timeText.ToString();
}
So, That’s OK.
But when i try to reset it (With Whole level);
#pragma strict
var isSaveDucks = false ;
var GameOver : GameObject;
function OnMouseDown()
{
if (isSaveDucks) {
Application.LoadLevel(2);
}
if(!isSaveDucks) {
CountPoints.Score = 0;
Timer.countDownSeconds = 15;
Application.LoadLevel(Application.loadedLevel);
Time.timeScale = 1;
}
}
It is not working Timer goes 0:0-1, 0:0-2 etc. I didn’t understand why ? Could some one explain this for me please
Thanks a lot.
(If i write something wrong sorry for my english ^_^)