using UnityEngine;
using System.Collections;

public class movespawner : MonoBehaviour {
	public float radiusdistance;
	public float degreestart;
	float thistime = 0f;
	float spawningtime;
	float spawntimer;
	public GameObject type1;
	public GameObject type2;


	// Use this for initialization
	void Start () {
		transform.position = new Vector3(radiusdistance,0f,0f);
		spawningtime = Random.Range(1f,3f);
	}
	 
	// Update is called once per frame
	void Update () {

		thistime += Time.deltaTime;
		spawntimer+= Time.deltaTime;

		if(spawntimer>= spawningtime)
		{
			//spawningtime = 0.2f;
			spawningtime = Random.Range(3f,6f);
			spawntimer = 0f;
			Instantiate(type1,this.transform.position,this.transform.rotation);
			
		}


		if(thistime>= 12)
			thistime = 0f;

		float test = (thistime+ degreestart)* 30f * Mathf.Deg2Rad;

		Mathf.Cos(test);
		transform.position = new Vector3(Mathf.Cos(test)*radiusdistance, Mathf.Sin(test)*radiusdistance, 0f);
	}
}
