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.

139 lines
3.2 KiB

  1. using UnityEngine.UI;
  2. using UnityEngine;
  3. public class MainMenuControllerServer : MonoBehaviour
  4. {
  5. public GameObject MainMenu;
  6. public GameObject SettingsMenu;
  7. public GameObject AboutMenu;
  8. public GameObject CreditsMenu;
  9. public Button SoundButton;
  10. public Button MusicButton;
  11. public Button DifficultyButton;
  12. public Button playerMovesButton;
  13. //On Awake
  14. private void Awake()
  15. {
  16. MainMenu.SetActive(true);
  17. SettingsMenu.SetActive(false);
  18. AboutMenu.SetActive(false);
  19. CreditsMenu.SetActive(false);
  20. }
  21. //Main Menu Options
  22. public void OnPlayClick()
  23. {
  24. UnityEngine.SceneManagement.SceneManager.LoadScene("Lobby");
  25. }
  26. public void OnQuitClick()
  27. {
  28. Application.Quit();
  29. }
  30. public void OnAboutClick()
  31. {
  32. //toggle which menu displays
  33. MainMenu.SetActive(false);
  34. AboutMenu.SetActive(true);
  35. }
  36. public void OnCreditClick()
  37. {
  38. //toggle which menu displays
  39. MainMenu.SetActive(false);
  40. CreditsMenu.SetActive(true);
  41. }
  42. public void OnSettingsClick()
  43. {
  44. //toggle which menu displays
  45. MainMenu.SetActive(false);
  46. SettingsMenu.SetActive(true);
  47. }
  48. //Settings Menu
  49. public void OnBackSettingsClick ()
  50. {
  51. //Settings menu
  52. SettingsMenu.SetActive (false);
  53. MainMenu.SetActive (true);
  54. }
  55. public void OnBackAboutClick ()
  56. {
  57. //about menu
  58. AboutMenu.SetActive (false);
  59. MainMenu.SetActive (true);
  60. }
  61. public void OnBackCreditClick ()
  62. {
  63. //about menu
  64. CreditsMenu.SetActive (false);
  65. MainMenu.SetActive (true);
  66. }
  67. //Settings menu
  68. public void OnMusicVolumeClick()
  69. {
  70. if (GlobalVariables.musicVolume == true)
  71. {
  72. //backgroundMusic.Stop();
  73. MusicButton.GetComponentInChildren<Text>().text = "Music Volume: OFF";
  74. GlobalVariables.musicVolume = false;
  75. }
  76. else
  77. {
  78. //backgroundMusic.Play();
  79. MusicButton.GetComponentInChildren<Text>().text = "Music Volume: ON";
  80. GlobalVariables.musicVolume = true;
  81. }
  82. }
  83. //Settings menu
  84. public void OnSoundVolumeClick ()
  85. {
  86. if (GlobalVariables.soundVolume == true) {
  87. SoundButton.GetComponentInChildren<Text> ().text = "Sound Volume: OFF";
  88. GlobalVariables.soundVolume = false;
  89. } else {
  90. SoundButton.GetComponentInChildren<Text> ().text = "Sound Volume: ON";
  91. GlobalVariables.soundVolume = true;
  92. }
  93. }
  94. public void OnDifficultyClick()
  95. {
  96. if (GlobalVariables.difficulty == 1)
  97. {
  98. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: MEDIUM";
  99. GlobalVariables.difficulty = 2;
  100. }
  101. else if (GlobalVariables.difficulty == 2)
  102. {
  103. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: HARD";
  104. GlobalVariables.difficulty = 3;
  105. }
  106. else
  107. {
  108. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: EASY";
  109. GlobalVariables.difficulty = 1;
  110. }
  111. }
  112. public void OnDisplayPlayerMoves()
  113. {
  114. if (GlobalVariables.playerMoves == true)
  115. {
  116. playerMovesButton.GetComponentInChildren<Text>().text = "Display Player Moves: OFF";
  117. GlobalVariables.playerMoves = false;
  118. }
  119. else
  120. {
  121. playerMovesButton.GetComponentInChildren<Text>().text = "Display Player Moves: ON";
  122. GlobalVariables.playerMoves = true;
  123. }
  124. }
  125. }