using UnityEngine;
using System;
using System.Collections.Generic;
using mgaia.Utils;

namespace mgaia.tk2d.Animations
{
    public class Tk2dSpriteScaleAnimation : AbstractCodeAnimation
    {
        private tk2dBaseSprite[] mSprites;

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

        protected override void Lerp(ValueType fromValue, ValueType toValue, float normalizedTime)
        {
            mSprites.ForEach(sprite => sprite.scale = Vector3.Lerp((Vector3)fromValue, (Vector3)toValue, normalizedTime));
        }

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