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


public class pauseMenu : MonoBehaviour
{
   
    public Button pauseButton;
    public Button resumeButton;
    public Button restartButton;
    public Button quitButton;
    public GameObject pauseMenus;
    public bool paused = false;
    public GameObject GameplayUI;
    //public rewardAds intAds;
    public bool canrestart = false;
    //public MenuLoading loading;
    public GameObject loadingbar;
    void Start()
    {
        pauseButton.onClick.AddListener(pause);
        resumeButton.onClick.AddListener(resume);
        restartButton.onClick.AddListener(restart);
        quitButton.onClick.AddListener(quit);
        
    }
    void Update()
    {
        if(paused)
        {
            //GameplayUI.SetActive(false);
            pauseMenus.SetActive(true);
            Time.timeScale = 0f;
        }
        
        else
        {
           GameplayUI.SetActive(true);
           pauseMenus.SetActive(false);
           Time.timeScale = 1f;
        }

        /*if (intAds.disablerestart)
        {
            canrestart = false;
        }*/
    }

    public void pause() 
    {
        paused = true;
        
    }
    public void resume() 
    {
        paused = false;
        
    }
    public void restart()
    {
        canrestart = true;
        //intAds.ShowAd();
        
        //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }
    public void quit()
    {
        //loadingbar.SetActive(true);
        SceneManager.LoadScene("Menu");
        //loading.StartLoading();
    }
   
}
