using UnityEngine;
using System.Collections;

public class MapGen : MonoBehaviour {

	public GameObject[] neutr;
	public GameObject[] enemy;
	public GameObject[] targets;


	public int ring_nb=4;
	public int start_nb = 5;

	public float start_dis = 10;

	public float increse_nr_build_rate = 0.25f;
	public float increse_distance_rate = 0.25f;
	public float rotate_range = 15f;
	public float translate_range = 4f;


	void OnGUI () {
		if (GUILayout.Button("Gen") ) {
			Gen ();
		}
	}

	void Gen() {
		int building_nb = start_nb;
		float radius = start_dis;
		for ( int i =0; i < ring_nb ; i ++ ) {
			building_nb += (int ) (building_nb*i*increse_nr_build_rate);
			radius += radius*i*increse_distance_rate;
			float deg = 360f/building_nb;
			for ( int k = 0; k < building_nb ; k ++ ) {
				GameObject g = (GameObject ) Instantiate(GetType()[GetIndex()]);
				g.transform.parent = transform;
				float t = Random.value*translate_range - translate_range;
				g.transform.localPosition = new Vector3(0,0,radius + t);
				float r = Random.value*rotate_range - rotate_range;
				g.transform.RotateAround(transform.position,transform.up,deg + r);
			}
		}
	}

	int GetIndex () {
		return 0;
	}

	GameObject[] GetType() {
		return neutr;
	}
	
}
