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

public class BoostSpawner : MonoBehaviour {

	[SerializeField] GameObject windMaker;
	BoxCollider box;
	Transform thisTF;
	void Start () 
	{
		box = GetComponent<BoxCollider> ();
		thisTF = GetComponent<Transform> ();
	}

	void Spawn () 
	{
		float point = -box.size.x /2;

		point += Random.Range (0f,500f);

			
		while (point < box.size.x / 2) {
			
			float offest = Random.Range (-box.size.z / 2, box.size.z / 2);
			if (Random.Range (0, 100) < 35) { //percent chance that boost spawns
				GameObject newWind = Instantiate (windMaker, thisTF.position + box.center + Vector3.right * point, thisTF.rotation) as GameObject;
				newWind.GetComponent<WindCreator> ().tilt = Random.Range (-0.1f, 0.1f);
				newWind.GetComponent<WindCreator> ().CreateWind ();
			}
			point += Random.Range (20f, 102f);
			
		}
	}
}
