/Scripts/ABGui.js

http://acid-and-base.googlecode.com/ · JavaScript · 55 lines · 44 code · 5 blank · 6 comment · 8 complexity · 1d2f9174a95ea3718394bd107dd95c2f MD5 · raw file

  1. var MenuActive:boolean = false;
  2. var scale : Texture2D;
  3. function OnGUI ()
  4. {
  5. //shows mouse if menu is onscreen
  6. if(MenuActive == true)
  7. Screen.showCursor = true;
  8. else
  9. Screen.showCursor = false;
  10. //Show the contents of the menu if it is active
  11. if(MenuActive == true)
  12. {
  13. // Make a background box
  14. GUI.Box (Rect ((Screen.width-200)/2,(Screen.height-100)/2,200,100), "Menu");
  15. 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");
  16. // This button will remove the menu from view.
  17. if (GUI.Button (Rect ((Screen.width-190)/2,(Screen.height-60)/2,180,30), "Continue"))
  18. {
  19. MenuActive = !MenuActive;
  20. Time.timeScale = 1;
  21. }
  22. // This button will restart the level.
  23. if (GUI.Button (Rect ((Screen.width-190)/2,(Screen.height)/2,180,30), "Restart Level"))
  24. {
  25. Application.LoadLevel ("Garden");
  26. }
  27. var pha = GameObject.Find("Acid").GetComponent("Properties").ph;
  28. var phb = GameObject.Find("Base").GetComponent("Properties").ph;
  29. GUI.Label(Rect(Screen.width - scale.width,0,scale.width, scale.height), scale);
  30. GUI.Label(Rect(Screen.width - scale.width + 32*pha - 13, 12, 10, 20),"A");
  31. GUI.Label(Rect(Screen.width - scale.width + 32*phb - 14, 32, 10, 20), "B");
  32. }
  33. }
  34. function LateUpdate()
  35. {
  36. //pressing ESC shows the menu
  37. if (Input.GetKeyDown(KeyCode.Escape))
  38. {
  39. if(MenuActive)
  40. {
  41. MenuActive = false;
  42. Time.timeScale = 1;
  43. }
  44. else
  45. {
  46. MenuActive=true;
  47. Time.timeScale = 0;
  48. }
  49. }
  50. }