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.

146 lines
3.2 KiB

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