PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Scripts/ABGui.js

http://acid-and-base.googlecode.com/
JavaScript | 55 lines | 44 code | 5 blank | 6 comment | 8 complexity | 1d2f9174a95ea3718394bd107dd95c2f MD5 | raw file
 1var MenuActive:boolean = false; 
 2var scale : Texture2D;
 3
 4function OnGUI () 
 5{ 
 6	//shows mouse if menu is onscreen
 7	if(MenuActive == true)     
 8		Screen.showCursor = true;
 9	else
10		Screen.showCursor = false;
11	
12	//Show the contents of the menu if it is active
13	if(MenuActive == true)
14	{
15		// Make a background box
16		GUI.Box (Rect ((Screen.width-200)/2,(Screen.height-100)/2,200,100), "Menu");
17		GUI.Box(Rect(0,0,300,90), "W,A,S,D - Move\nQ - Switch Character\nE - Interact/Pickup & Drop Item\nLeft Mouse Button - Camera Control\nESC - Pause\n");
18		// This button will remove the menu from view.
19		if (GUI.Button (Rect ((Screen.width-190)/2,(Screen.height-60)/2,180,30), "Continue")) 
20		{
21			MenuActive = !MenuActive;
22			Time.timeScale = 1;
23		}
24		// This button will restart the level.
25		if (GUI.Button (Rect ((Screen.width-190)/2,(Screen.height)/2,180,30), "Restart Level")) 
26		{
27			Application.LoadLevel ("Garden");
28		}
29		
30		var pha = GameObject.Find("Acid").GetComponent("Properties").ph;
31		var phb = GameObject.Find("Base").GetComponent("Properties").ph;
32		
33		GUI.Label(Rect(Screen.width - scale.width,0,scale.width, scale.height), scale);
34		GUI.Label(Rect(Screen.width - scale.width + 32*pha - 13, 12, 10, 20),"A");
35		GUI.Label(Rect(Screen.width - scale.width + 32*phb - 14, 32, 10, 20), "B");
36	}
37} 
38
39function LateUpdate()
40{
41	//pressing ESC shows the menu
42	if (Input.GetKeyDown(KeyCode.Escape))
43	{
44		if(MenuActive)
45		{
46			MenuActive = false;
47			Time.timeScale = 1;
48		}
49		else
50		{
51			MenuActive=true; 
52			Time.timeScale = 0;
53		}
54	}
55}