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.

123 lines
2.8 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 SettingsMenu;
  9. public GameObject MainMenu;
  10. public GameObject HowToPlayMenu;
  11. public Button SoundButton;
  12. public Button MusicButton;
  13. public Button DifficultyButton;
  14. bool soundVolume = true;
  15. bool musicVolume = true;
  16. int difficulty = 1;
  17. //On Awake
  18. private void Awake ()
  19. {
  20. MainMenu.SetActive (true);
  21. SettingsMenu.SetActive (false);
  22. GameOptionsMenu.SetActive (false);
  23. HowToPlayMenu.SetActive (false);
  24. }
  25. //Main Menu Options
  26. public void OnPlayClick ()
  27. {
  28. //toggle which menu displays
  29. MainMenu.SetActive (false);
  30. GameOptionsMenu.SetActive (true);
  31. }
  32. public void OnSettingsClick ()
  33. {
  34. //toggle which menu displays
  35. MainMenu.SetActive (false);
  36. SettingsMenu.SetActive (true);
  37. }
  38. public void OnTutorialClick ()
  39. {
  40. MainMenu.SetActive (false);
  41. HowToPlayMenu.SetActive (true);
  42. }
  43. public void OnTutorialContinueClick ()
  44. {
  45. UnityEngine.SceneManagement.SceneManager.LoadScene ("TuteLevelOne");
  46. }
  47. //Game Options and Settings Menu
  48. public void OnBackClick ()
  49. {
  50. GameOptionsMenu.SetActive (false);
  51. SettingsMenu.SetActive (false);
  52. MainMenu.SetActive (true);
  53. }
  54. //Game Options Menu
  55. public void OnRecompileRaceClick ()
  56. {
  57. UnityEngine.SceneManagement.SceneManager.LoadScene ("ReCompileRaceOne");
  58. }
  59. public void OnColourCollideClick ()
  60. {
  61. UnityEngine.SceneManagement.SceneManager.LoadScene ("ColourCollideOne");
  62. }
  63. public void OnChickenRunClick ()
  64. {
  65. UnityEngine.SceneManagement.SceneManager.LoadScene ("ChickenRunOne");
  66. }
  67. //Settings menu
  68. public void OnSoundVolumeClick ()
  69. {
  70. if (soundVolume == true) {
  71. SoundButton.GetComponentInChildren<Text> ().text = "Sound Volume: OFF";
  72. soundVolume = false;
  73. } else {
  74. SoundButton.GetComponentInChildren<Text> ().text = "Sound Volume: ON";
  75. soundVolume = true;
  76. }
  77. }
  78. public void OnMusicVolumeClick ()
  79. {
  80. if (musicVolume == true) {
  81. //backgroundMusic.Stop();
  82. MusicButton.GetComponentInChildren<Text> ().text = "Music Volume: OFF";
  83. musicVolume = false;
  84. } else {
  85. //backgroundMusic.Play();
  86. MusicButton.GetComponentInChildren<Text> ().text = "Music Volume: ON";
  87. musicVolume = true;
  88. }
  89. }
  90. public void OnDifficultyClick ()
  91. {
  92. if (difficulty == 1)
  93. {
  94. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: MEDIUM";
  95. difficulty = 2;
  96. }
  97. else if(difficulty == 2)
  98. {
  99. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: HARD";
  100. difficulty = 3;
  101. }
  102. else
  103. {
  104. DifficultyButton.GetComponentInChildren<Text>().text = "Difficulty: EASY";
  105. difficulty = 1;
  106. }
  107. }
  108. }