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.

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