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

public class MenuScript : MonoBehaviour
{
    [SerializeField] int menuLayer; // Shows at what layer the current Menu is and what esc should do
    [SerializeField] GameObject defaultMenu;
    [SerializeField] GameObject settingsMenu;

    // Update is called once per frame
    void Update()
    {
        escPressed();
    }

    public void escPressed()
    {
        if(Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown("o"))
        {
            if(menuLayer == 0)
            {
                defaultMenu.SetActive(true);
                Cursor.lockState = CursorLockMode.None;
                menuLayer = 1;
            }
            else if(menuLayer == 1)
            {
                defaultMenu.SetActive(false);
                lockCursor();
                menuLayer = 0;
            }
            else if(menuLayer == 2)
            {
                settingsMenu.SetActive(false);
                defaultMenu.SetActive(true);
                menuLayer = 1;
            }
        }
    }

    public void setMenuLayer(int i)
    {
        menuLayer = i;
    }

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

    public void lockCursor()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }
}
