using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour
{
public GameObject asteroidsGenerator;
public GUIText guiTextScore;
public int timeInterval = 1;
public float delayTime = 2f;
float time;
int totalTime;
void Start ()
{
Instantiate(asteroidsGenerator, Vector3.zero, Quaternion.identity);
time = 0f;
totalTime = 0;
}
void Update ()
{
time += Time.deltaTime;
if(AsteroidsGenerator.isActive)
{
if(time >= timeInterval)
{
totalTime += timeInterval;
guiTextScore.text = "X " + totalTime.ToString();
time = 0f;
}
}
else
GameOver();
}
IEnumerator GameOver()
{
guiTextScore.text = "Your Total Score Is:" + totalTime.ToString();
yield return StartCoroutine(MyDelayMethod(delayTime));
Application.LoadLevel(2);
}
IEnumerator MyDelayMethod(float delay)
{
yield return new WaitForSeconds(delay);
}
}
Well this my code, not sure what im doing wrong, is there any other way to implement the delay?