using UnityEngine;
using System.Collections;

public class LightColor : MonoBehaviour
{
    public Light[] lights;
    public GameObject[] lightColorBG;
    public bool disableByDefault;

    private void Awake()
    {
        if(disableByDefault)
        {
            DisableLights();
        }
    }

    public void SetLightColor(Color lightCol, Color bgCol)
    {
        if (lightCol != Color.clear)
        {
            for (int i = 0; i < lights.Length; i++)
            {
                lights[i].color = lightCol;
            }
        }

        for (int i = 0; i < lightColorBG.Length; i++)
        {
            Debug.Log(i + " set col: " + bgCol.ToString());
            lightColorBG[i].GetComponent<Renderer>().material.SetColor("_MainTex", bgCol);
        }
    }

    public void EnableLights()
    {
        for (int i = 0; i < lights.Length; i++)
        {
            lights[i].enabled = true;
        }

        for (int i = 0; i < lightColorBG.Length; i++)
        {
            lightColorBG[i].SetActive(true);
        }
    }

    public void DisableLights()
    {
        for (int i = 0; i < lights.Length; i++)
        {
            lights[i].enabled = false;
        }

        for (int i = 0; i < lightColorBG.Length; i++)
        {
            lightColorBG[i].SetActive(false);
        }
    }
}
