using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.SceneManagement;

public class AutoDeath : MonoBehaviour {
  public string Message;
  public float DieAfter;

  private float timer;
  private bool triggered = false;

  private void Start() {
    timer = DieAfter;
    UI.Instance.ShowInfo(Message);
  }

  private void Update() {
    timer -= Time.deltaTime;

    if (timer < 0f && !triggered) {
      triggered = true;
      UI.Instance.FadeOutScene().OnComplete(
          () => SceneManager.LoadScene(SceneManager.GetActiveScene().name));
    }
  }
}
