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

public class GameEndController : MonoBehaviour
{
    public RawImage rawImage;

    public float timeSinceLastFlicker;
    public float flickerSpeed;

    public float timeOff;
    public float timeSpentOff;


    private void Update()
    {
        Cursor.visible = false;

        if (timeSinceLastFlicker >= flickerSpeed && rawImage.enabled)
        {
            timeSinceLastFlicker = 0;

            rawImage.enabled = false;
        }

        if (!rawImage.enabled)
        {
            timeSpentOff += Time.deltaTime;
        }

        if (timeSpentOff >= timeOff && !rawImage.enabled)
        {
            timeSpentOff = 0;

            rawImage.enabled = true;
        }

        if (rawImage.enabled)
        {
            timeSinceLastFlicker += Time.deltaTime;
        }



        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(0);
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            Application.Quit();
        }

    }
}
