using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[RequireComponent(typeof(AudioSource))]
public class LaserButton : MonoBehaviour {

	[SerializeField] List<GameObject> mirrors;
	Interact interact;

	void Awake ()
	{
		interact = GetComponent<Interact> ();
	}

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		if (interact.Interacted())
		{
			foreach (GameObject e in mirrors)
			{
				if (!e) continue;

				e.GetComponent<Mirror>().Flip();
			}

			foreach (GameObject e in GameObject.FindGameObjectsWithTag ("laser"))
			{
				if (!e) continue;

				e.GetComponent<Laser>().UpdateLaser();
			}
			audio.Play ();
		}
	}
}
