using UnityEngine;
using System.Collections;

public class DartBlock : MonoBehaviour {
	public bool isFacingLeft;
	public bool isGrey;
	public bool isEnabled = true;
	float shootTime;
	float lastShot;
	

	// Use this for initialization
	void Start () {
		isEnabled = true;
		shootTime = 2.0f;
		lastShot = Time.time;
	}
	
	// Update is called once per frame
	void Update () {
		if ( (lastShot + shootTime) <= Time.time){
			//Shoot
			if (isEnabled){
				//Only shoot if not disabled
				GameObject temp = (GameObject)Instantiate(Resources.Load ((isGrey ? "DartGrey" : "Dart")), transform.FindChild("ShootFrom").GetComponentInChildren<Transform>().position, new Quaternion(0,0,0,0));
				temp.GetComponent<DartMovement>().isFacingLeft = isFacingLeft;
				temp.GetComponent<DartMovement>().parent = this.gameObject;
			}
			lastShot = Time.time;
		}
	}
}
