using UnityEngine;
using System.Collections;

public class respawnSheep : MonoBehaviour
{

	public Transform sheepPrefab;
	public int requiredSheep;
	public int maxSheepBatch;
	public int minSheepBatch;
	public float horz;
	public float vert;
	public GameObject self;

	// Use this for initialization
	void Start ()
	{
		self = gameObject;
	}
	
	// Update is called once per frame
	void Update ()
	{

		if (GameObject.FindGameObjectsWithTag ("Sheep").Length < requiredSheep)
			for (int i = Random.Range(minSheepBatch,maxSheepBatch); i > 0; i--) {
				(Instantiate (sheepPrefab, new Vector3 (Random.Range (-horz, horz), vert, transform.position.z), Quaternion.identity)as Transform).gameObject.GetComponent<feastOnSheep> ().Manager = self;
			}

	}
}
