using UnityEngine;
using System.Collections;

public class LampScript : MonoBehaviour {

	public GeneratorScript generator;
	
	public Light[] lights;
	
	public GameObject[] litObjs;
	public GameObject[] litObjsB;
	public Material litMat;
	public Material litMatB;
	
	private bool swapped = false;
	
	// Update is called once per frame
	void Update () {
		if (generator.on){
			for (int i=0; i<lights.Length; i++){
				lights[i].enabled = true;
			}
			if (!swapped){
				for (int i=0; i<litObjs.Length; i++){
					litObjs[i].renderer.material = litMat;
				}
				for (int i=0; i<litObjsB.Length; i++){
					litObjsB[i].renderer.material = litMatB;
				}
				
				swapped = true;
			}
		}else{
			for (int i=0; i<lights.Length; i++){
				lights[i].enabled = false;
			}
		}
	}
}
