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

public class AdeptFactory : MonoBehaviour {

	public GameObject adeptPrefab;
	public AdeptSpawner adeptSpawner;

	List<Adept> population;

	public Sprite[] maskSprites;

	static AdeptFactory _instance;

	static public AdeptFactory instance {
		// using lazy instantiation here... 
		get{
			return _instance;
		}
	}
	
	void Awake(){
		_instance = this;
		population = new List<Adept>();
	}

	public void CreateAdept(){
		Adept adept = GameObject.Instantiate(adeptPrefab).GetComponent<Adept>();
		adept.targetCheckpoint = Ellipse.instance.AddEllipseCkpt();
		population.Add (adept);
		adeptSpawner.SpawnAdept(adept);
	}

	public void KillAdept(Adept adept){
		population.Remove(adept);
		Ellipse.instance.RemoveEllipseCkpt(adept.targetCheckpoint);
		GameObject.Destroy(adept.gameObject);
		GameManager.instance.CheckAdepts();
	}

	public int GetAliveAdepts(){
		return population.Count;
	}
}
