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

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

        public LightColorAnimation(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.color = Color.Lerp((Color)fromValue, (Color)toValue, normalizedTime));
        }

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