You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.5 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. public class Menu : MonoBehaviour {
  4. public GameObject player1;
  5. public GameObject player2;
  6. public GameObject player3;
  7. public GameObject player4;
  8. public GameObject musicTrad;
  9. public GameObject musicEpic;
  10. private bool start = false;
  11. private bool menu = true;
  12. private float goreCount = 20;
  13. private string music = "Traditional";
  14. // Use this for initialization
  15. void Start () {
  16. }
  17. // Update is called once per frame
  18. void Update () {
  19. player1.GetComponent<playerController> ().confettiOnHit = (int) goreCount;
  20. player2.GetComponent<playerController> ().confettiOnHit = (int) goreCount;
  21. player3.GetComponent<playerController> ().confettiOnHit = (int) goreCount;
  22. player4.GetComponent<playerController> ().confettiOnHit = (int) goreCount;
  23. if (Input.GetKeyDown ("escape")) {
  24. if (menu)
  25. start = false;
  26. else
  27. start = !start;
  28. menu = false;
  29. }
  30. if (start || menu)
  31. Time.timeScale = 0;
  32. else
  33. Time.timeScale = 1;
  34. if (Input.GetKey(KeyCode.F12))
  35. AudioListener.volume = 0.0f;
  36. if (Input.GetKey(KeyCode.F11))
  37. AudioListener.volume = 1.0f;
  38. }
  39. void OnGUI ()
  40. {
  41. if (start) {
  42. // Make a background box
  43. GUI.Box (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 150, 200, 300), "Menu");
  44. // Make the first button.
  45. if (GUI.Button (new Rect (Screen.width / 2 - 90, Screen.height / 2 - 130, 180, 80), "Options")) {
  46. start = false;
  47. menu = true;
  48. }
  49. // Make the second button.
  50. if (GUI.Button (new Rect (Screen.width / 2 - 90, Screen.height / 2 - 40, 180, 80), "Reset Level")) {
  51. Application.LoadLevel ("Lachlan_jump_work");
  52. start = false;
  53. }
  54. // Make the second button.
  55. if (GUI.Button (new Rect (Screen.width / 2 - 90, Screen.height / 2 + 50, 180, 80), "Exit")) {
  56. Application.Quit ();
  57. }
  58. }
  59. if (menu) {
  60. GUI.Box (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 150, 200, 300), "Options");
  61. if (GUI.Button (new Rect (Screen.width / 2 - 95, Screen.height / 2 - 120, 90, 30), "1 Player")) {
  62. player1.SetActive(true);
  63. player2.SetActive(false);
  64. player3.SetActive(false);
  65. player4.SetActive(false);
  66. }
  67. if (GUI.Button (new Rect (Screen.width / 2+ 5 , Screen.height / 2 - 120, 90, 30), "2 Players")) {
  68. player1.SetActive(true);
  69. player2.SetActive(true);
  70. player3.SetActive(false);
  71. player4.SetActive(false);
  72. }
  73. if (GUI.Button (new Rect (Screen.width / 2 - 95, Screen.height / 2 - 85, 90, 30), "3 Players")) {
  74. player1.SetActive(true);
  75. player2.SetActive(true);
  76. player3.SetActive(true);
  77. player4.SetActive(false);
  78. }
  79. if (GUI.Button (new Rect (Screen.width / 2+ 5 , Screen.height / 2 - 85, 90, 30), "4 Players")) {
  80. player1.SetActive(true);
  81. player2.SetActive(true);
  82. player3.SetActive(true);
  83. player4.SetActive(true);
  84. }
  85. goreCount= (int) GUI.HorizontalSlider(new Rect(Screen.width/2 -90, Screen.height/2 - 10, 180, 20), goreCount, 0.0F, 200);
  86. GUI.Label(new Rect(Screen.width/2 - 11, Screen.height/2 +5, 200, 70), "" +goreCount);
  87. GUI.Label(new Rect(Screen.width/2 - 30, Screen.height/2 -30, 200, 70), "Confetti Count");
  88. if (GUI.Button (new Rect (Screen.width / 2-90 , Screen.height / 2 +50, 90, 30), "Music")) {
  89. if (music =="Epic"){
  90. music = "Traditional";
  91. musicEpic.SetActive(false);
  92. musicTrad.SetActive(true);
  93. }
  94. }
  95. GUI.Label(new Rect(Screen.width/2 +5, Screen.height/2 +55, 90, 30), "" +music);
  96. if (GUI.Button (new Rect (Screen.width / 2-90 , Screen.height / 2 +90, 180, 30), "Exit Menu")) {
  97. menu = false;
  98. }
  99. }
  100. }
  101. }