using UnityEngine;
using System.Collections;

public class LaserUnlocker : MonoBehaviour {

	private bool hudEnabled;
	private float countdown;

	private float offsetX;
	private float offsetY;

	void Awake(){
		renderer.enabled = false;
		hudEnabled = false;
		countdown = 0.0f;
		offsetX = 0.0f;
		offsetY = 0.0f;
	}

	void FixedUpdate () {
		if(hudEnabled){

			offsetX = Random.Range (-1 * Constants.TEXT_SHAKE_MAGNITUDE, Constants.TEXT_SHAKE_MAGNITUDE);
			offsetY = Random.Range (-1 * Constants.TEXT_SHAKE_MAGNITUDE, Constants.TEXT_SHAKE_MAGNITUDE);

			transform.position = new Vector3 (offsetX,-3.6f + offsetY, transform.position.z);		
			if(countdown < Constants.LASER_TEXT_TIME){
				countdown += Time.deltaTime;
			} else {
				Destroy(this.gameObject);
			}
		}
	}

	public void Activate(){
		hudEnabled = true;
		renderer.enabled = true;
	}
}
