using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Monitor : MonoBehaviour
{
    
    public static float onTime = 8f;
    public static float delay = 1f;
    public static float onTimeLeft = 0f;

    public GameObject on;
    public GameObject off;
    
    // Start is called before the first frame update
    void Start()
    {
        Light.contributions.Add(gameObject, 0f);
    }

    public void reset()
    {
        onTimeLeft = 0f;
    }

    // Update is called once per frame
    void Update()
    {
        onTimeLeft -= Time.deltaTime;

        if (0f < onTimeLeft && onTimeLeft < (onTime - delay))
        {
            on.SetActive(true);
            off.SetActive(false);
            Light.contributions[gameObject] = 0.5f;
        }
        else
        {
            on.SetActive(false);
            off.SetActive(true);
            Light.contributions[gameObject] = 0f;
        }
    }

    public void switchOn()
    {
        onTimeLeft = onTime;
    }

    private void OnMouseDown()
    {
        onTimeLeft = 0f;
    }
}
