/Scripts/ABGui.js
http://acid-and-base.googlecode.com/ · JavaScript · 55 lines · 44 code · 5 blank · 6 comment · 8 complexity · 1d2f9174a95ea3718394bd107dd95c2f MD5 · raw file
- var MenuActive:boolean = false;
- var scale : Texture2D;
- function OnGUI ()
- {
- //shows mouse if menu is onscreen
- if(MenuActive == true)
- Screen.showCursor = true;
- else
- Screen.showCursor = false;
-
- //Show the contents of the menu if it is active
- if(MenuActive == true)
- {
- // Make a background box
- GUI.Box (Rect ((Screen.width-200)/2,(Screen.height-100)/2,200,100), "Menu");
- 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");
- // This button will remove the menu from view.
- if (GUI.Button (Rect ((Screen.width-190)/2,(Screen.height-60)/2,180,30), "Continue"))
- {
- MenuActive = !MenuActive;
- Time.timeScale = 1;
- }
- // This button will restart the level.
- if (GUI.Button (Rect ((Screen.width-190)/2,(Screen.height)/2,180,30), "Restart Level"))
- {
- Application.LoadLevel ("Garden");
- }
-
- var pha = GameObject.Find("Acid").GetComponent("Properties").ph;
- var phb = GameObject.Find("Base").GetComponent("Properties").ph;
-
- GUI.Label(Rect(Screen.width - scale.width,0,scale.width, scale.height), scale);
- GUI.Label(Rect(Screen.width - scale.width + 32*pha - 13, 12, 10, 20),"A");
- GUI.Label(Rect(Screen.width - scale.width + 32*phb - 14, 32, 10, 20), "B");
- }
- }
- function LateUpdate()
- {
- //pressing ESC shows the menu
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- if(MenuActive)
- {
- MenuActive = false;
- Time.timeScale = 1;
- }
- else
- {
- MenuActive=true;
- Time.timeScale = 0;
- }
- }
- }