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.

161 lines
3.8 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. public class menuContrller : MonoBehaviour {
  5. public GameObject menu;
  6. public GameObject options;
  7. public GameObject levelSelect;
  8. public GameObject instructions;
  9. public GameObject xboxLayout;
  10. public GameObject btn_1player;
  11. public GameObject btn_2player;
  12. public GameObject btn_3player;
  13. public GameObject btn_4player;
  14. public GameObject txt_score;
  15. public GameObject txt_confetti;
  16. public levelController control;
  17. public GameObject alpaca;
  18. public GameObject platypuss;
  19. public GameObject goat;
  20. public GameObject kangaroo;
  21. private bool p1Enabled = false;
  22. private bool p2Enabled = false;
  23. private bool p3Enabled = false;
  24. private bool p4Enabled = false;
  25. // Use this for initialization
  26. void Start () {
  27. control = GameObject.FindGameObjectWithTag ("GameController").GetComponent<levelController> ();
  28. }
  29. // Update is called once per frame
  30. void Update () {
  31. if (Input.GetAxisRaw ("Vertical_P1") == 1) {
  32. Debug.Log("button hit");
  33. p1Enabled = true;
  34. btn_1player.GetComponent<Image> ().color = Color.green;
  35. }
  36. if (Input.GetAxisRaw ("Vertical_P2") == 1) {
  37. p2Enabled = true;
  38. btn_2player.GetComponent<Image> ().color = Color.green;
  39. }
  40. if (Input.GetAxisRaw ("Vertical_P3") == 1) {
  41. p3Enabled = true;
  42. btn_3player.GetComponent<Image> ().color = Color.green;
  43. }
  44. if (Input.GetAxisRaw ("Vertical_P4") == 1) {
  45. p4Enabled = true;
  46. btn_4player.GetComponent<Image> ().color = Color.green;
  47. }
  48. }
  49. public void panelSelect (string panel){
  50. btn_1player.GetComponent<Image> ().color = Color.grey;
  51. btn_2player.GetComponent<Image> ().color = Color.grey;
  52. btn_3player.GetComponent<Image> ().color = Color.grey;
  53. btn_4player.GetComponent<Image> ().color = Color.grey;
  54. p1Enabled = false;
  55. p2Enabled = false;
  56. p3Enabled = false;
  57. p4Enabled = false;
  58. menu.SetActive (false);
  59. options.SetActive (false);
  60. levelSelect.SetActive (false);
  61. instructions.SetActive (false);
  62. xboxLayout.SetActive (false);
  63. alpaca.SetActive (true);
  64. goat.SetActive (true);
  65. platypuss.SetActive (true);
  66. kangaroo.SetActive (true);
  67. if (panel == "menu")
  68. menu.SetActive (true);
  69. if (panel =="options")
  70. options.SetActive (true);
  71. if (panel == "levelSelect") {
  72. levelSelect.SetActive (true);
  73. alpaca.SetActive (false);
  74. goat.SetActive (false);
  75. platypuss.SetActive (false);
  76. kangaroo.SetActive (false);
  77. }
  78. if (panel == "instructions") {
  79. instructions.SetActive (true);
  80. alpaca.SetActive (false);
  81. goat.SetActive (false);
  82. platypuss.SetActive (false);
  83. kangaroo.SetActive (false);
  84. }
  85. if (panel == "xboxLayout") {
  86. xboxLayout.SetActive (true);
  87. alpaca.SetActive (false);
  88. goat.SetActive (false);
  89. platypuss.SetActive (false);
  90. kangaroo.SetActive (false);
  91. }
  92. }
  93. public void playerSelect (int players){
  94. control.playerCount = players;
  95. if (players == 1) {
  96. btn_1player.GetComponent<Image> ().color = Color.green;
  97. p1Enabled = true;
  98. }
  99. if (players == 2) {
  100. btn_2player.GetComponent<Image> ().color = Color.green;
  101. p2Enabled = true;
  102. }
  103. if (players == 3) {
  104. btn_3player.GetComponent<Image> ().color = Color.green;
  105. p3Enabled = true;
  106. }
  107. if (players == 4) {
  108. btn_4player.GetComponent<Image> ().color = Color.green;
  109. p4Enabled = true;
  110. }
  111. }
  112. public void levelStart (string level){
  113. control.p1Enabled = p1Enabled;
  114. control.p2Enabled = p2Enabled;
  115. control.p3Enabled = p3Enabled;
  116. control.p4Enabled = p4Enabled;
  117. if (p1Enabled || p2Enabled || p3Enabled || p4Enabled)
  118. Application.LoadLevel (level);
  119. }
  120. public void scoreChange (float score){
  121. txt_score.GetComponent<Text> ().text = "" + Mathf.RoundToInt(score);
  122. control.maxScore = Mathf.RoundToInt (score);
  123. }
  124. public void confettiSlider (float confetti){
  125. txt_confetti.GetComponent<Text> ().text = "" + Mathf.RoundToInt(confetti);
  126. control.confetti = Mathf.RoundToInt (confetti);
  127. }
  128. }