using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameController : MonoBehaviour {

    public GameObject StartPanel;
    public GameObject HelpPanel;
    public GameObject CreditPanel;
    public GameObject GamePanel;
    public GameObject PausePanel;
    public GameObject WinPanel;
    public GameObject LosePanel;

    public LevelController CurrentLevel;

    public enum Views
    {
        Start,
        Help,
        Credits,
        Game,
        Pause,
        Win,
        Lose,
    }



    private GameObject activeView;

    public static GameController Current { get; private set; }

    private void Awake()
    {
        Current = this;
        activeView = GamePanel;
    }

    void Start()
    {
        StartPanel.SetActive(false);
        HelpPanel.SetActive(false);
        CreditPanel.SetActive(false);
        PausePanel.SetActive(false);
        WinPanel.SetActive(false);
        LosePanel.SetActive(false);
        SetView(StartPanel);
    }

    public void StartGame()
    {
        SetView(GamePanel);
    }

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

    public void SetView(Views view)
    {
        switch (view)
        {
            case Views.Start:
                SetView(StartPanel);
                return;
            case Views.Help:
                SetView(HelpPanel);
                return;
            case Views.Credits:
                SetView(CreditPanel);
                return;
            case Views.Game:
                SetView(GamePanel);
                return;
            case Views.Pause:
                SetView(PausePanel);
                return;
            case Views.Win:
                SetView(WinPanel);
                return;
            case Views.Lose:
                SetView(LosePanel);
                return;
        }
    }

    void SetView(GameObject view)
    {
        if (ReferenceEquals(view, activeView)) return;

        activeView.SetActive(false);
        view.SetActive(true);

		if (ReferenceEquals(activeView, GamePanel) || ReferenceEquals(view, GamePanel))
		{
			CurrentLevel.gameObject.SetActive(GamePanel.activeInHierarchy);
		}
        activeView = view;
    }


}
