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.
 
 

105 lines
1.9 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GUIController : MonoBehaviour {
public static GUIController Instance {
get;
set;
}
public GameObject mainMenu;
public GameObject settingsMenu;
public GameObject audioMenu;
public GameObject lobby;
public MenuState state;
void Awake() {
Instance = this;
}
void Start() {
state = MenuState.Main;
}
public void OnStartButtonClicked() {
mainMenu.SetActive(false);
Island.Instance.RotateToZero();
state = MenuState.Hidden;
}
public void OnSettingsButtonClicked() {
mainMenu.SetActive(false);
settingsMenu.SetActive(true);
Island.Instance.MoveLeft();
state = MenuState.Settings;
}
public void OnAudioButtonClicked() {
settingsMenu.SetActive(false);
audioMenu.SetActive(true);
state = MenuState.Audio;
}
public void OnSettingsBackButtonClicked() {
settingsMenu.SetActive(false);
mainMenu.SetActive(true);
Island.Instance.MoveRight();
state = MenuState.Main;
}
public void OnAudioBackButtonClicked() {
audioMenu.SetActive(false);
settingsMenu.SetActive(true);
state = MenuState.Settings;
}
public void OnMusicSliderVolumeChanged(float value) {
SettingsManager.Instance.SetMusicsVolume(value);
}
public void OnSFXSliderVolumeChanged(float value) {
SettingsManager.Instance.SetSFXVolume(value);
}
public void ShowLobby() {
if (lobby != null) {
lobby.SetActive(true);
state = MenuState.Lobby;
}
}
public void ShowMenu() {
mainMenu.SetActive(true);
state = MenuState.Main;
}
public void OpenMenu() {
if (state == MenuState.Lobby) {
mainMenu.SetActive(false);
Island.Instance.FreeRotate();
CameraController.Instance.MoveOnMenu();
state = MenuState.Hidden;
}
}
public void OnQuitButtonClicked() {
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
public enum MenuState {
Main,
Settings,
Lobby,
Audio,
Hidden
}