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.

123 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. }
  35. void OnGUI ()
  36. {
  37. if (start) {
  38. // Make a background box
  39. GUI.Box (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 150, 200, 300), "Menu");
  40. // Make the first button.
  41. if (GUI.Button (new Rect (Screen.width / 2 - 90, Screen.height / 2 - 130, 180, 80), "Options")) {
  42. start = false;
  43. menu = true;
  44. }
  45. // Make the second button.
  46. if (GUI.Button (new Rect (Screen.width / 2 - 90, Screen.height / 2 - 40, 180, 80), "Reset Level")) {
  47. Application.LoadLevel ("Lachlan_jump_work");
  48. start = false;
  49. }
  50. // Make the second button.
  51. if (GUI.Button (new Rect (Screen.width / 2 - 90, Screen.height / 2 + 50, 180, 80), "Exit")) {
  52. Application.Quit ();
  53. }
  54. }
  55. if (menu) {
  56. GUI.Box (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 150, 200, 300), "Options");
  57. if (GUI.Button (new Rect (Screen.width / 2 - 95, Screen.height / 2 - 120, 90, 30), "1 Player")) {
  58. player1.SetActive(true);
  59. player2.SetActive(false);
  60. player3.SetActive(false);
  61. player4.SetActive(false);
  62. }
  63. if (GUI.Button (new Rect (Screen.width / 2+ 5 , Screen.height / 2 - 120, 90, 30), "2 Players")) {
  64. player1.SetActive(true);
  65. player2.SetActive(true);
  66. player3.SetActive(false);
  67. player4.SetActive(false);
  68. }
  69. if (GUI.Button (new Rect (Screen.width / 2 - 95, Screen.height / 2 - 85, 90, 30), "3 Players")) {
  70. player1.SetActive(true);
  71. player2.SetActive(true);
  72. player3.SetActive(true);
  73. player4.SetActive(false);
  74. }
  75. if (GUI.Button (new Rect (Screen.width / 2+ 5 , Screen.height / 2 - 85, 90, 30), "4 Players")) {
  76. player1.SetActive(true);
  77. player2.SetActive(true);
  78. player3.SetActive(true);
  79. player4.SetActive(true);
  80. }
  81. goreCount= (int) GUI.HorizontalSlider(new Rect(Screen.width/2 -90, Screen.height/2 - 10, 180, 20), goreCount, 0.0F, 200);
  82. GUI.Label(new Rect(Screen.width/2 - 11, Screen.height/2 +5, 200, 70), "" +goreCount);
  83. GUI.Label(new Rect(Screen.width/2 - 30, Screen.height/2 -30, 200, 70), "Confetti Count");
  84. if (GUI.Button (new Rect (Screen.width / 2-90 , Screen.height / 2 +50, 90, 30), "Music")) {
  85. if (music =="Epic"){
  86. music = "Traditional";
  87. musicEpic.SetActive(false);
  88. musicTrad.SetActive(true);
  89. }
  90. else if (music =="Traditional"){
  91. music = "Epic";
  92. musicEpic.SetActive(true);
  93. musicTrad.SetActive(false);
  94. }
  95. }
  96. GUI.Label(new Rect(Screen.width/2 +5, Screen.height/2 +55, 90, 30), "" +music);
  97. if (GUI.Button (new Rect (Screen.width / 2-90 , Screen.height / 2 +90, 180, 30), "Exit Menu")) {
  98. menu = false;
  99. }
  100. }
  101. }
  102. }