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.

134 lines
3.1 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine.UI;
  4. using UnityEngine;
  5. public class MainMenuController : MonoBehaviour
  6. {
  7. public GameObject GameOptionsMenu;
  8. public GameObject GameOpt_S1;
  9. public GameObject GameOpt_S2;
  10. public GameObject SettingsMenu;
  11. public GameObject MainMenu;
  12. public GameObject HowToPlayMenu;
  13. public Button SoundButton;
  14. public Button MusicButton;
  15. public Button DifficultyButton;
  16. bool soundVolume = true;
  17. bool musicVolume = true;
  18. int difficulty = 1;
  19. //On Awake
  20. private void Awake ()
  21. {
  22. MainMenu.SetActive (true);
  23. SettingsMenu.SetActive (false);
  24. GameOptionsMenu.SetActive (false);
  25. GameOpt_S1.SetActive (false);
  26. GameOpt_S2.SetActive (false);
  27. HowToPlayMenu.SetActive (false);
  28. }
  29. //Main Menu Options
  30. public void OnPlayClick ()
  31. {
  32. //toggle which menu displays
  33. MainMenu.SetActive (false);
  34. GameOptionsMenu.SetActive (true);
  35. GameOpt_S1.SetActive (true);
  36. }
  37. public void OnSettingsClick ()
  38. {
  39. //toggle which menu displays
  40. MainMenu.SetActive (false);
  41. SettingsMenu.SetActive (true);
  42. }
  43. public void OnTutorialClick ()
  44. {
  45. MainMenu.SetActive (false);
  46. HowToPlayMenu.SetActive (true);
  47. }
  48. public void OnTutorialContinueClick ()
  49. {
  50. UnityEngine.SceneManagement.SceneManager.LoadScene ("TuteLevelOne");
  51. }
  52. //Game Options and Settings Menu
  53. public void OnBackClick ()
  54. {
  55. //Settings menu
  56. GameOptionsMenu.SetActive (false);
  57. SettingsMenu.SetActive (false);
  58. MainMenu.SetActive (true);
  59. }
  60. public void OnBackClickScreenOne ()
  61. {
  62. //Game Options Screen One back to Main Menu
  63. GameOptionsMenu.SetActive (false);
  64. GameOpt_S1.SetActive (false);
  65. MainMenu.SetActive (true);
  66. }
  67. public void OnBackClickScreenTwo ()
  68. {
  69. //Game Options Screen Two back to Screen One
  70. GameOpt_S1.SetActive (true);
  71. GameOpt_S2.SetActive (false);
  72. }
  73. //Game Options S1 to S2
  74. public void OnContinueClick ()
  75. {
  76. //Game Options Screen Two back to Screen One
  77. GameOpt_S1.SetActive (false);
  78. GameOpt_S2.SetActive (true);
  79. }
  80. //Settings menu
  81. public void OnSoundVolumeClick ()
  82. {
  83. if (soundVolume == true) {
  84. SoundButton.GetComponentInChildren<Text> ().text = "Sound Volume: OFF";
  85. soundVolume = false;
  86. } else {
  87. SoundButton.GetComponentInChildren<Text> ().text = "Sound Volume: ON";
  88. soundVolume = true;
  89. }
  90. }
  91. public void OnMusicVolumeClick ()
  92. {
  93. if (musicVolume == true) {
  94. //backgroundMusic.Stop();
  95. MusicButton.GetComponentInChildren<Text> ().text = "Music Volume: OFF";
  96. musicVolume = false;
  97. } else {
  98. //backgroundMusic.Play();
  99. MusicButton.GetComponentInChildren<Text> ().text = "Music Volume: ON";
  100. musicVolume = true;
  101. }
  102. }
  103. public void OnDifficultyClick ()
  104. {
  105. if (difficulty == 1)
  106. {
  107. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: MEDIUM";
  108. difficulty = 2;
  109. }
  110. else if(difficulty == 2)
  111. {
  112. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: HARD";
  113. difficulty = 3;
  114. }
  115. else
  116. {
  117. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: EASY";
  118. difficulty = 1;
  119. }
  120. }
  121. }