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

public class Spawner : MonoBehaviour 
{
	public Missile missile;
	public float randomizer = 50;
	public float randomizerIncrement = 0.5f;
	public float shootingDelay = 0.5f;

	void Start ()
	{
		StartCoroutine (SpawnMissiles ());
	}

	IEnumerator SpawnMissiles ()
	{
		while (true)
		{
			if (Random.Range (0, 101) < randomizer)
			{
				Instantiate (missile, this.gameObject.transform.position, Quaternion.identity);
			}

			yield return new WaitForSeconds (shootingDelay);

			randomizer += randomizerIncrement;
		}
	}
}
