Hello, I am trying to make a drop down game that requires the player to keep their score between a certain set of numbers. That I have figured out, what I need help with is that I want a timer to start when the player gets outside of the pre determined range and if the player get his score back within the range I want the timer to stop and reset letting play continue. The loss condition is loading another level btw if that help for any reason.
//Drew Hilvers
var redStyle : GUIStyle; //style for redtext
var greenStyle : GUIStyle; //style for greentext
var scoreStyle : GUIStyle; // style for overall score
var countDownIsActive : boolean; // boolean for whether or not timer should be running
function Update()
{
if(PlayerStatus.count > 12 || PlayerStatus.count < 8 countDownIsActive == false)
{
countDownIsActive = true;
}
if(PlayerStatus.count <= 12 || PlayerStatus.count <= 8 countDownIsActive == true)
{
countDownIsActive = false;
}
Debug.Log(countDownIsActive);
if (countDownIsActive == true;)
{
yield WaitForSeconds(5);
Application.LoadLevel("lost");
}
}
function OnGUI ()
{
GUI.Label (Rect (450,40,100,100), "" + PlayerStatus.score, scoreStyle);
if(PlayerStatus.count <= 12 || PlayerStatus.count <= 8)
{
GUI.Label (Rect (10,40,100,100), "" + PlayerStatus.count, greenStyle);
}
if(PlayerStatus.count > 12 || PlayerStatus.count < 8)
{
GUI.Label (Rect (10,40,100,100), "" + PlayerStatus.count, redStyle);
}
}
The error I get now is that if you get back in range before the 5 seconds run out you still lose and go to the “lost” level.
I double checked my typing(should have just copied and pasted like this time) and this is my current script that has no errors just doesn’t do what I would like it to.
//Drew Hilvers
var redStyle : GUIStyle; //style for redtext
var greenStyle : GUIStyle; //style for greentext
var scoreStyle : GUIStyle; // style for overall score
var countDownIsActive : boolean; // boolean for whether or not timer should be running
function Update()
{
if(PlayerStatus.count > 12 || PlayerStatus.count < 8 countDownIsActive == false)
{
countDownIsActive = true;
}
if(PlayerStatus.count <= 12 PlayerStatus.count >= 8 countDownIsActive == true)
{
countDownIsActive = false;
}
Debug.Log(countDownIsActive);
if (countDownIsActive == true)
{
countdown();
}
}
function countdown()
{
yield WaitForSeconds(5);
Application.LoadLevel("lost");
}
function OnGUI ()
{
GUI.Label (Rect (450,40,100,100), "" + PlayerStatus.score, scoreStyle);
if(PlayerStatus.count <= 12 PlayerStatus.count >= 8)
{
GUI.Label (Rect (10,40,100,100), "" + PlayerStatus.count, greenStyle);
}
if(PlayerStatus.count > 12 || PlayerStatus.count < 8)
{
GUI.Label (Rect (10,40,100,100), "" + PlayerStatus.count, redStyle);
}
}