using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class UIController : MonoBehaviour {

    private bool paused = false;
    public GameObject pauseMenu;
    public GameObject gameOverMenu;

    public Slider masterSlider;
    public Slider musicSlider;
    public Slider SFXSlider;

	// Use this for initialization
	void Start () {
        if (pauseMenu.activeSelf)
            pauseMenu.SetActive(false);
        gameOverMenu.SetActive(false);
        /*masterSlider.value = SoundController.instance.masterVolume;
        musicSlider.value = SoundController.instance.musicVolume;
        SFXSlider.value = SoundController.instance.sfxVolume;
        */
	}
	
	// Update is called once per frame
	void Update () {
        if (Input.GetKeyUp(KeyCode.Escape)) {
            ToggleMenu();
        }
	}

    public void GameOver() {
        Debug.Log("Game over called in UI COntroller");
        gameOverMenu.SetActive(true);
        Time.timeScale = 1;        
    }

    public void LoadLevel(string levelname) {
        SceneManager.LoadScene(levelname);
    }

    public void ToggleMenu() {
        Debug.Log("Toggle Menu");
        if (paused)
        {
            
            Time.timeScale = 1;
            Debug.Log("Toggle Menu back on");
            paused = false;
            pauseMenu.SetActive(false);
        }
        else {
            paused = true;
            //show menu
            pauseMenu.SetActive(true);

            //pause game
            Time.timeScale = 0;
        }            
    }

    public void Quit() {
        AppHelper.Quit();
    }

    public void Restart() {
        Debug.Log("Restart Game");
    }

    public void SetMasterVolume(float val) {
        SoundController.instance.SetMasterVolume(val);
    }

    public void SetMusicVolume(float val) {
        SoundController.instance.SetMusicVolume(val);
    }

    public void SetSFXVolume(float val) {
        SoundController.instance.SetSFXVolume(val);
    }
}
