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

public class Group : MonoBehaviour {
	
	public GameObject obj;
	public int count = 5;
	[HideInInspector]
	public List<GameObject> a = new List<GameObject>();

	// Use this for initialization
	protected void Start () {
		for(int i =0;i< count;i++){
			GameObject g = Instantiate(obj) as GameObject;
			g.transform.parent = transform;
			//g.transform.position+=transform.position;
			g.transform.localPosition=Vector3.zero;
			a.Add(g);
		}
	}
	
	public delegate void apply(GameObject obj, int index);
	
	//function should takea gameObject and an index
	public void applyToAll(apply func){
		for(int i =0;i< a.Count;i++){
			func(a[i] as GameObject,i);
		}
	}

	public GameObject at(int i){
		return a[i] as GameObject;
	}

	public int length(){
		return a.Count;
	}
}
