displaying teext.text=“RIGHT ANSWER”…u can see it in my code …plz see my if loop of right and wrong button…
in my game i want to display “RIGHT ANSWER” disable it before i am calling Start() function in my if loop…but problem is i am not
able to disable GUITEXT…i hv also used texxt.enabled = false; but still not able to disable it…plz help…here is my code
#pragma strict
var rand1:int;
var rand2:int;
var rand3:int;
var rand4:int;
var ran:int;
var currTry:int = 0; //Increment when click on button
var maxTry:int = 100; //check for max allowed inputs
//public var currentTime : int = 0;
var score : int = 0;
var guiScore : GUIText;
var texxt:GUIText;
//var timer: GUIText;
//var timee: float =0.0;
function Start()
{
ran = Random.Range(0,3);
rand1 = Random.Range(0, 20);//Random number1
rand2= Random.Range(0,20);//Random number2
rand3= Random.Range(0,40);//Random number3
if(ran == 0)
{
rand4 = rand1 + rand2; //Internally calculation
}
if(ran == 1)
{
if(rand2>rand1)
rand4 = rand2 - rand1;
else
rand4 = rand1 -rand2;
}
if(ran == 2)
{
rand4 = (rand1 * rand2);
}
//Debug.Log(rand4);
//InvokeRepeating( "CountDown", 1, 2 );
//Invoke("Countdown",10);
}
//function Update()
// {
//GetComponent(GUIText).text = Time.time.ToString();
//GetComponent(GUIText).text = parseInt(Time.time).ToString();
// }
//function CountDown()
// {
// if (--currentTime == 0)
//{
// Debug.Log("Time is up my friend");
// CancelInvoke( "CountDown" );
//Destroy(this.gameObject);
// }
//}
function OnGUI()
{
//Debug.Log(rand4);
if(currTry < maxTry) //check if we
{
GUI.Box (Rect (30,5,25,30), rand1.ToString());//first random number
GUI.Box (Rect (90,5,25,30), rand2.ToString());//second random number
GUI.Box (Rect (150,5,25,30), rand3.ToString());//third random number
//GUI.Box (Rect (60,5,25,30),"+");//for +symbol
GUI.Box (Rect (60,5,25,30),GetRandomOperator());
GUI.Box (Rect (120,5,25,30),"=");//for equals to
if(GUI.Button(Rect(10,70,50,30),"right"))//GUI button for right
{
currTry++; //Increment Here
if(rand4 == rand3)
{
//texxt.text = "RIGHT ANSWER";
Debug.Log("RIGHT ANSWER");
// score += 10;
//guiScore.text = "Score: " + score;
Start();
texxt.enabled = false;
}
else
{
texxt.text = "WRONG ANSWER";
texxt.enabled = false;
Debug.Log("WRONG ANSWER");
Destroy(this.gameObject);
}
}
if(GUI.Button(Rect(90,70,50,30),"wrong"))//GUI button for wrong
{
currTry++; //Increment Here Again
if(rand4 != rand3)
{
texxt.text = "RIGHT ANSWER";
texxt.enabled = false;
Debug.Log("UR ANSWER IS RIGHT");
//score += 10;
//guiScore.text = "Score: " + score;
Start();
}
else
{
texxt.text = "WRONG ANSWER";
texxt.enabled = false;
//cubeRenderer.material.color == Color.red;
Debug.Log("WRONG AAA");
Destroy(this.gameObject);
}
}
}
else
{
Debug.Log("-----------------------------------MAX TRY COMPLETED-------------------------------");
///Do Something else after 20 Try Done
}
}
function GetRandomOperator()
{
//var ran:int;
//ran = Random.Range(0,4);
switch(ran)
{
case (0):
return"+";
case (1):
return"-";
case (2):
return"*";
}
}