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.

135 lines
3.2 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. UnityEngine.SceneManagement.SceneManager.LoadScene ("LoginScreen");
  37. }
  38. public void OnSettingsClick ()
  39. {
  40. //toggle which menu displays
  41. MainMenu.SetActive (false);
  42. SettingsMenu.SetActive (true);
  43. }
  44. public void OnTutorialClick ()
  45. {
  46. MainMenu.SetActive (false);
  47. HowToPlayMenu.SetActive (true);
  48. }
  49. public void OnTutorialContinueClick ()
  50. {
  51. UnityEngine.SceneManagement.SceneManager.LoadScene ("TuteLevelOne");
  52. }
  53. //Game Options and Settings Menu
  54. public void OnBackClick ()
  55. {
  56. //Settings menu
  57. GameOptionsMenu.SetActive (false);
  58. SettingsMenu.SetActive (false);
  59. MainMenu.SetActive (true);
  60. }
  61. public void OnBackClickScreenOne ()
  62. {
  63. //Game Options Screen One back to Main Menu
  64. GameOptionsMenu.SetActive (false);
  65. GameOpt_S1.SetActive (false);
  66. MainMenu.SetActive (true);
  67. }
  68. public void OnBackClickScreenTwo ()
  69. {
  70. //Game Options Screen Two back to Screen One
  71. GameOpt_S1.SetActive (true);
  72. GameOpt_S2.SetActive (false);
  73. }
  74. //Game Options S1 to S2
  75. public void OnContinueClick ()
  76. {
  77. //Game Options Screen Two back to Screen One
  78. GameOpt_S1.SetActive (false);
  79. GameOpt_S2.SetActive (true);
  80. }
  81. //Settings menu
  82. public void OnSoundVolumeClick ()
  83. {
  84. if (soundVolume == true) {
  85. SoundButton.GetComponentInChildren<Text> ().text = "Sound Volume: OFF";
  86. soundVolume = false;
  87. } else {
  88. SoundButton.GetComponentInChildren<Text> ().text = "Sound Volume: ON";
  89. soundVolume = true;
  90. }
  91. }
  92. public void OnMusicVolumeClick ()
  93. {
  94. if (musicVolume == true) {
  95. //backgroundMusic.Stop();
  96. MusicButton.GetComponentInChildren<Text> ().text = "Music Volume: OFF";
  97. musicVolume = false;
  98. } else {
  99. //backgroundMusic.Play();
  100. MusicButton.GetComponentInChildren<Text> ().text = "Music Volume: ON";
  101. musicVolume = true;
  102. }
  103. }
  104. public void OnDifficultyClick ()
  105. {
  106. if (difficulty == 1)
  107. {
  108. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: MEDIUM";
  109. difficulty = 2;
  110. }
  111. else if(difficulty == 2)
  112. {
  113. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: HARD";
  114. difficulty = 3;
  115. }
  116. else
  117. {
  118. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: EASY";
  119. difficulty = 1;
  120. }
  121. }
  122. }