using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class GUIManager : MonoBehaviour {

    public enum GameStateType {
        Gameplay,
        Paused,
        Dead
    }

    public GameObject ScrTitle;
    public GameObject ScrExposition;
    public GameObject ScrPaused;
    public GameObject ScrGameplay;
    public GameObject ScrDeath;
    public GameObject ScrCredits;

    public AudioClip SfxButton;
    public Camera mainCamera;

    public bool Paused; //if this is true, the game's paused

    public GameStateType GameState;
    private static GUIManager instance = null;
    public static GUIManager Instance { get { return instance; } }



    void Awake() {
        //this is for my singleton
        instance = this;
    }

    // Use this for initialization
    void Start() {

        GameState = GameStateType.Paused;
        ScrTitle.SetActive(true);
    }

    // Update is called once per frame
    void Update() {

        if (Input.GetKeyDown(KeyCode.P) == true) {
            print("p pressed");
            OnBtnPaused();
        }

        //if the title screen is currently up
        if (ScrGameplay.activeSelf == true) {

            /*if (Input.GetKey(KeyCode.Return) || Input.GetButton("Fire1")) {
                OnBtnStart();
            }*/
        }
    }

    public void OnBtnPaused() {

        //if you are already paused, return to gameplay.
        if (GameState == GameStateType.Paused) {
            GameState = GameStateType.Gameplay;
            ScrGameplay.SetActive(true);
            ScrPaused.SetActive(false);
        } else {
            if (GameState == GameStateType.Gameplay) {
                GameState = GameStateType.Paused;
                ScrGameplay.SetActive(false);
                ScrPaused.SetActive(true);
            }
        }
    }

    public void OnBtnStart() {

        GameState = GameStateType.Paused;

        ScrTitle.SetActive(false);
        ScrExposition.SetActive(true);
        //SceneManager.LoadScene("GameScene");

    }

    public void OnBtnExposition() {

        //GameState = GameStateType.Gameplay;

        ScrExposition.SetActive(false);
        ScrGameplay.SetActive(true);
        //SceneManager.LoadScene("Build One");

    }

    public void OnBtnCredits() {
        ScrTitle.SetActive(false);
        ScrCredits.SetActive(true);
    }

    public void OnReturnToTitle() {
        SceneManager.LoadScene("MainMenu");
    }

    public void OnStartGame() {
        SceneManager.LoadScene("GameScene");
    }

    public void OnBtnSound() {
        GetComponent<AudioSource>().PlayOneShot(SfxButton);
    }

	public void OnButtonExit() {
		Application.Quit();
	}
}
