using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameManagerScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}

	void OnGUI()
	{

	}

	public void RespawnCall()
	{
		Invoke ("RespawnAllObjects", 3.5f);

	}

	void RespawnAllObjects()
	{
		GameObject[] respawnableObjects_Enemy;
		GameObject respawnableObjects_Player;
		GameObject object_Owl;

		respawnableObjects_Enemy  = GameObject.FindGameObjectsWithTag("Hazard");
		respawnableObjects_Player = GameObject.FindGameObjectWithTag ("Player");
		object_Owl = GameObject.FindGameObjectWithTag ("OwlTag");


		for (int i = 0; i < respawnableObjects_Enemy.Length; i++) {

			if (respawnableObjects_Enemy [i].GetComponent<RespawnGeneric> () != null)
				respawnableObjects_Enemy [i].GetComponent<RespawnGeneric> ().ResetToSpawn ();

			if (respawnableObjects_Enemy [i].GetComponent<KillBoxScript> () != null) {

				respawnableObjects_Enemy [i].GetComponent<KillBoxScript> ().DestroyOnRespawn ();
			}
		}
		respawnableObjects_Player.GetComponent<RespawnGeneric> ().ResetToSpawn ();
		object_Owl.GetComponent<Enemy_OwlScript> ().OwlTimerReset ();

	}
}
