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

public class BoundaryLightManager : MonoBehaviour
{
    public Light currentLight;
    public float startIntensity;
    public float lightLifeTime;

    private float _currentTick;

    private void Awake()
    {
        currentLight.intensity = startIntensity;
        _currentTick = 0.0f;
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        currentLight.intensity = Mathf.Lerp(startIntensity, 0, _currentTick / lightLifeTime);
        if (_currentTick >= lightLifeTime)
        {
            Destroy(gameObject);
        }
        else
        {
            _currentTick = Mathf.Clamp(_currentTick + Time.deltaTime, 0, lightLifeTime);           
        }
    }
}
