using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;

public class Light : MonoBehaviour
{

    private float lightLevel = 0f;
    public SpriteRenderer darkness;

    public static Dictionary<GameObject, float> contributions = new Dictionary<GameObject, float>();
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        lightLevel = contributions.Values.Sum();
        lightLevel = Mathf.Clamp01(lightLevel);
        Color c = Color.black;
        c.a = 0.5f * (1 - lightLevel);
        darkness.color = c;
        
        SleepDepth.subtract(lightLevel * lightLevel * Time.deltaTime *
                            (Timer.Instance.oversleeping ? .5f : 1f)); // Nerf if oversleeping
    }
}
