using UnityEngine.UI;
using UnityEngine;

public class MainMenuControllerServer : MonoBehaviour
{
	public GameObject MainMenu;
    public GameObject SettingsMenu;
    public GameObject AboutMenu;
	public GameObject CreditsMenu;
    public Button MusicButton;
	public Button playerMovesButton;
    public AudioSource backgroundMusic;

    private void Awake()
    {
        MainMenu.SetActive(true);
        SettingsMenu.SetActive(false);
		AboutMenu.SetActive(false);
		CreditsMenu.SetActive(false);
    }

    public void OnPlayClick()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Lobby");
    }
    public void OnQuitClick()
    {
        Application.Quit();
    }

	public void OnAboutClick()
	{
		MainMenu.SetActive(false);
		AboutMenu.SetActive(true);
	}

	public void OnCreditClick()
	{
		MainMenu.SetActive(false);
		CreditsMenu.SetActive(true);
	}

    public void OnSettingsClick()
    {
        MainMenu.SetActive(false);
        SettingsMenu.SetActive(true);
    }

	public void OnBackSettingsClick ()
	{
		SettingsMenu.SetActive (false);
		MainMenu.SetActive (true);
	}

	public void OnBackAboutClick ()
	{
		AboutMenu.SetActive (false);
		MainMenu.SetActive (true);
	}

	public void OnBackCreditClick ()
	{
		CreditsMenu.SetActive (false);
		MainMenu.SetActive (true);
	}

    public void OnMusicVolumeClick()
    {
		if (GlobalVariables.musicVolume == true)
        {
            backgroundMusic.Stop();
            MusicButton.GetComponentInChildren<Text>().text = "Music Volume: OFF";
			GlobalVariables.musicVolume = false;
        }
        else
        {
            backgroundMusic.Play();
            MusicButton.GetComponentInChildren<Text>().text = "Music Volume: ON";
			GlobalVariables.musicVolume = true;
        }
    }

	public void OnDisplayPlayerMoves()
	{
		if (GlobalVariables.playerMoves == true)
		{
			playerMovesButton.GetComponentInChildren<Text>().text = "Display Player Moves: OFF";
			GlobalVariables.playerMoves = false;
		}
		else
		{
			playerMovesButton.GetComponentInChildren<Text>().text = "Display Player Moves: ON";
			GlobalVariables.playerMoves = true;
		}
	}
}
