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

public class MesclasScript : MonoBehaviour
{
    public bool mainMen;
    public bool credit;
    public bool winner;
    public bool gamePlay;
    public float contador;
    public Text relogio;
    // Start is called before the first frame update
    void Start()
    {
        contador = 0;
    }

    // Update is called once per frame
    void Update()
    {
        if(gamePlay && FindObjectOfType<Npc001>().termAFase && contador <= 5f)
        {
            SceneManager.LoadScene("Winner");
        }
        else
        {
            if (gamePlay && FindObjectOfType<Npc001>().termAFase)
            {
                contador += 1 * Time.deltaTime;
            }
        }
        if(mainMen && Input.GetButtonDown("Cancel"))
        {
            Debug.Log("Deu Quit");
            Application.Quit();
        }
        if(credit && Input.GetButtonDown("Cancel"))
        {
            SceneManager.LoadScene("MainMenu");
        }
        if (winner&& contador <= 20)
        {
            contador += 1 * Time.deltaTime;
            relogio.text = PlayerPrefs.GetFloat("Minutos").ToString("#") + ":" + PlayerPrefs.GetFloat("Segundos").ToString("#");
        }
        else
        {
            if (winner)
            {
                SceneManager.LoadScene("Creditos");
            }
        }
        if(winner&& Input.GetButtonDown("Cancel"))
        {
            SceneManager.LoadScene("Creditos");
        }
    }
    public void Sair()
    {
        SceneManager.LoadScene("MainMenu");
    }
    public void Quit()
    {
        Application.Quit();
    }
    public void Jogar()
    {
        SceneManager.LoadScene("GamePlay");
    }
    public void Creditos()
    {
        SceneManager.LoadScene("Creditos");
    }
}
