using UnityEngine;
using System.Collections;

public class LightController : MonoBehaviour {

	public float fadeSpeed = 2f;            // How fast the light fades between intensities.
	public float highIntensity = 2f;        // The maximum intensity of the light whilst on.
	public bool On;                    // Whether or not the alarm is on.

	private float targetIntensity;
	
	void Start () {
		// When the level starts we want the light to be "off".
		light.intensity = 0f;
	}

	void Update () {
		// If the light is on...
		if(On)
			// ... Lerp the light's intensity towards the high
			light.intensity = Mathf.Lerp(light.intensity, highIntensity, fadeSpeed * Time.deltaTime);
		
		else
			// Otherwise fade the light's intensity to zero.
			light.intensity = Mathf.Lerp(light.intensity, 0f, fadeSpeed * Time.deltaTime);
	}
}
