using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
using static UnityEngine.Rendering.DebugUI;

public class PauseMenuController : MonoBehaviour
{
    [SerializeField] private GameObject pauseMenu;

    private bool pauseMenuOpened = false;

    public void PauseMenu(InputAction.CallbackContext context)
    {
        if (context.performed)
        {
            if (pauseMenuOpened)
            {
                ClosePauseMenu();
            }
            else
            {
                OpenPauseMenu();
            }
        }
    }

    public void OpenPauseMenu()
    {
        pauseMenu.SetActive(true);
        pauseMenuOpened = true;
        PauseGame();
    }

    public void ClosePauseMenu()
    {
        pauseMenu.SetActive(false);
        pauseMenuOpened = false;
        ResumeGame();
    }

    private void PauseGame()
    {
        Time.timeScale = 0;
    }
    private void ResumeGame()
    {
        Time.timeScale = 1;
    }
}
