Hey all,
I’m new to Javascript, and I put together some code for a simple rock paper scissors game I’m working on. I think I have the basic flow of how it will go, but it’s not quite there. I’d love any feedback I can get on the matter. Here is the code:
#pragma strict
var btn: UnityEngine.UI.Button = rock.GetComponent.<UnityEngine.UI.Button>();
var btn: UnityEngine.UI.Button = paper.GetComponent.<UnityEngine.UI.Button>();
var btn: UnityEngine.UI.Button = paper.GetComponent.<UnityEngine.UI.Button>();
function Update() {
if (btn: UnityEngine.UI.Button = rock.GetComponent.<UnityEngine.UI.Button>())
human=0;
if (btn: UnityEngine.UI.Button = paper.GetComponent.<UnityEngine.UI.Button>())
human=1;
if (btn: UnityEngine.UI.Button = paper.GetComponent.<UnityEngine.UI.Button>())
human=2;
if(human>-1){
var computer : int=Random.value * 3;
var results=0;
if(human == 0 computer == 2) results=1;
if(human == 1 computer == 0) results=1;
if(human == 2 computer == 1) results=1;
if(human == 0 computer == 1) results=-1;
if(human == 1 computer == 2) results=-1;
if(human == 2 computer == 0) results=-1;
if(results==-1)
GetComponent.<Text.Lose>().enabled = true;
if(results==0)
GetComponent.<Text.Draw>().enabled = true;
if(results==1)
GetComponent.<Text.Draw>().enabled = true;
}
}
Also, here’s the UI if this helps for reference 
Thanks!