42 lines
828 B
C#
42 lines
828 B
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using System.Collections;
|
|
using System.Timers;
|
|
|
|
public class GameOverScript : MonoBehaviour
|
|
{
|
|
public GameObject image;
|
|
private float elapsed;
|
|
|
|
[SerializeField]
|
|
private float duration = 2.0f;
|
|
|
|
[SerializeField]
|
|
private AudioSource audioSource;
|
|
|
|
void Start()
|
|
{
|
|
image.SetActive(false);
|
|
elapsed = 0.0f;
|
|
|
|
}
|
|
|
|
|
|
void Update()
|
|
{
|
|
elapsed += Time.deltaTime;
|
|
if(elapsed >= duration) {
|
|
image.SetActive(true);
|
|
if (audioSource != null)
|
|
{
|
|
audioSource.Play();
|
|
}
|
|
if (Input.anyKeyDown)
|
|
{
|
|
SceneManager.LoadScene(1, LoadSceneMode.Single);
|
|
TreeSpawner.treeCount = 0;
|
|
}
|
|
|
|
}
|
|
}
|
|
} |