using UnityEngine;
using System.Collections;

public class Airworld_BirdControl : MonoBehaviour
{

	public GameObject birdPrefab;
	public float birdSpawnTimer = 30;

	// Use this for initialization
	void Start ()
	{
		//InvokeRepeating ("SpawnBirds", 2, birdSpawnTimer);
		SpawnBirds ();
	}

	void SpawnBirds ()
	{
		float spawnX = Random.Range (-4, 4);
		float spawnY = Random.Range (-5, 5);
		float speedB = Random.Range (5, 8);
		float nextSpawn = Random.Range (9, 16);
		Vector3 spawnPos = gameObject.transform.position + new Vector3 (spawnX, spawnY, 0);
		GameObject bird = (GameObject)Instantiate (birdPrefab, spawnPos, Quaternion.identity); 
		bird.GetComponent <Airworld_BirdBrain> ().speed = speedB;

		Invoke ("SpawnBirds", nextSpawn);
	}

}
