using UnityEngine;
using System.Collections;

public class Shot : MonoBehaviour
{
	public Transform PrefabShot;
	public float shootingRate = 0.25f;
	
	private float shootCooldown;
	private Vector3 pos;

	void Start()
	{
		shootCooldown = 0f;
	}
	
	void Update()
	{
		if (shootCooldown > 0)
		{
			shootCooldown -= Time.deltaTime;
		}
	}
	
	public void doShot(bool isShot, float argX, float argY)
	{
		shootCooldown = shootingRate;

		var shotTransform = Instantiate(PrefabShot) as Transform;
		pos.x = argX;
		pos.y = argY;
		shotTransform.position = pos;//argPos;//transform.position;

        ShotMove beam = shotTransform.gameObject.GetComponent<ShotMove>();
		if (beam != null)
		{
			beam._isShot = isShot;
		}
	}
}