using DG.Tweening;
using UnityEngine;
using UnityEngine.SceneManagement;

public class DigGame : MonoBehaviour
{

	public static bool GameOver;
	public static void TriggerGameOver()
	{
		instance.DoGameOver();
	}

	private static DigGame instance;

	public Transform GameOverSign;
	public string GameOverScene;

    void Start()
    {
		GameOver = false;
		instance = this;
	}

	void Update()
	{
		if(Input.GetKeyDown(KeyCode.Escape))
		{
			Application.Quit();
		}
	}

	private void DoGameOver()
	{
		if (GameOver) // already done, don't dupe
			return;

		GameOver = true;
		GameOverSign.DOMoveY(2, 0.8f).SetEase(Ease.OutElastic).SetUpdate(true);
		Invoke("ChangeScene", 3.5f);
	}

	private void ChangeScene()
	{
		SceneManager.LoadScene(GameOverScene);
	}

}
