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

namespace mgaia.Utils.Animations
{
    public class LightIntensityAnimation : AbstractCodeAnimation
    {
        private Light[] mLights;

        public LightIntensityAnimation(float[] keyTimes, ValueType[] keyValues, ValueType initialValue, bool loop) : base(keyTimes, keyValues, initialValue, loop) { }

        protected override void Lerp(ValueType fromValue, ValueType toValue, float normalizedTime)
        {
            mLights.ForEach(light => light.intensity = Mathf.Lerp((float)fromValue, (float)toValue, normalizedTime));
        }

        protected override void OnActivateAnimation(object[] objs)
        {
            mLights = objs.Select(obj => obj as Light).ToArray();
        }
    }
}