using UnityEngine;
using System.Collections;

public class SoundWave : MonoBehaviour {

	public bool buttonPress;
	CircleCollider2D cirColl;
	private float step = 0.05f;
	private float final = 5f;
	Animator anim;
	public AudioClip beat;

	// Use this for initialization
	void Start () {

		cirColl = GetComponent<CircleCollider2D> ();
		cirColl.enabled = false;
		anim = GetComponent<Animator> ();
	
	}
	
	// Update is called once per frame
	void Update () {


		if (Input.GetButtonDown ("Fire2") && cirColl.radius != final) {
			
			cirColl.enabled = true;
			buttonPress = true;
			anim.SetBool ("buttonPress", true);
			AudioSource.PlayClipAtPoint (beat, transform.position);
		}
		if (cirColl.radius <= final && buttonPress) {
			cirColl.radius += step;
		} else {
			cirColl.radius = 0.1f;
			cirColl.enabled = false;
			buttonPress = false;
			anim.SetBool ("buttonPress", false);
		}
	}
}
