using UnityEngine;
using System.Collections;

public class TimeManager : MonoBehaviour {

	private int stage = 0;

	public GameObject preTime;
	public GameObject me;
	public GameObject world;
	public Vector3 spawnPoint;

	// Use this for initialization
	void Start () {
		preTime.SetActive(true);
		world.SetActive(false);
		//me.SetActive(false);
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetKeyDown (KeyCode.Escape)) Application.Quit ();
	}

	public void NextStage() {
		if (stage == 0) {
			preTime.SetActive(false);
			world.SetActive(true);
			Instantiate(me, new Vector3(-8f,2f,0f), Quaternion.identity);
			stage = 1;
		}
	}

	public void SpawnMe() {
		StartCoroutine(SpawnDelay());
	}

	private IEnumerator SpawnDelay() {
		yield return new WaitForSeconds (3f);
		GameObject go = (GameObject) Instantiate(me, spawnPoint, Quaternion.identity);
	}
}
