using UnityEngine;
using System.Collections;


[System.Serializable]
public class EnemyWave  {

	[SerializeField]
	public float height;

	[SerializeField]
	public float speed;

	[SerializeField]
	[Range(-1,1)]
	public int direction = -1;

	public float delay;

	public bool nothing;
}




public class GameManager1 : MonoBehaviour
{

	[SerializeField]
	public EnemyWave[] pattern;
	int patternProgress = 0;

	GameObject waveInstance;
	public GameObject wave;

	public Vector3 waveStart;

	void Start ()
	{
		StartCoroutine ("WaveSpawn");
	}

	void OnDrawGizmos()
	{
		Gizmos.DrawWireSphere (waveStart, 0.5f);
		Gizmos.color = Color.red;


	}


	IEnumerator WaveSpawn ()
	{
		


		yield return new WaitForSeconds (pattern [patternProgress].delay);


		if (pattern [patternProgress].nothing == false) {
			waveInstance = Instantiate (wave, waveStart, Quaternion.identity) as GameObject;

			waveInstance.GetComponent<Wave> ().height = pattern [patternProgress].height;
			waveInstance.GetComponent<Wave> ().direction = pattern [patternProgress].direction;
			waveInstance.GetComponent<Wave> ().speed = pattern [patternProgress].speed;
		}

		patternProgress++;


		if (patternProgress > pattern.Length-1) {
			patternProgress = 0;
		}

		print (patternProgress);

		StartCoroutine ("WaveSpawn");
	}

}
