using UnityEngine;
using System.Collections;

public class LightController : MonoBehaviour {

    Light l;
    float intensity;
    float minI, maxI;
    bool t = true;
    int i = 0;

    void Awake() {
        l = this.gameObject.GetComponent<Light>();
        minI = 0.5f;
        maxI = 2.0f;
        l.intensity = minI;
    }

    void Update() {
        int f = Random.Range(1, 2);

        if (i % 20 == 0) {
            float x = l.intensity;

            if (x >= maxI )      t = false;
            else if (x <= minI) t = true;

            if (t) {
                l.intensity += f/10.0f ;
            } else {
                l.intensity -= f/10.1f;
            }

            i = 0;
        }
        i++;
    }

}
