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

public class DebrisSpawner : MonoBehaviour {

	public float MIN_DEBRIS_SPEED = 100f;
	public float MAX_DEBRIS_SPEED = 300f;

	public float DEBRIS_RANGE = 800f;

	public float DebrisTiming = 2.5f;

	public List<GameObject> debris;

	// Use this for initialization
	void Start() {
		StartCoroutine(spawnDebris());
	}

	// Update is called once per frame
	void Update() {

	}


	public IEnumerator spawnDebris() {
		while (true) {
			yield return new WaitForSeconds(DebrisTiming);
			GameObject temp = Instantiate(debris[Random.Range(0,debris.Count)], transform.position + (Random.insideUnitSphere * Random.Range(0f, DEBRIS_RANGE)), Random.rotation);
			temp.GetComponent<Debris>().speed = Random.Range(MIN_DEBRIS_SPEED, MAX_DEBRIS_SPEED);
		}
	}
}
