using UnityEngine;
using System.Collections;

public class PlayAnim : TravellingThing
{

    public string animation;
    public float speed =1;
    public bool removeOnEnd;

    private SkeletonAnimation skeleton;

	// Use this for initialization
	void Start () {
        skeleton = GetComponent<SkeletonAnimation>();
        skeleton.skeleton.SetBonesToSetupPose();
        skeleton.state.SetAnimation(1, animation, !removeOnEnd);
        skeleton.timeScale = speed;
        if (removeOnEnd) skeleton.state.Complete += (Spine.AnimationState state, int trackIndex, int loopCount) => { Destroy(gameObject); };
	}

    public override void SetMultiplier(float multiplier)
    {
        skeleton.timeScale = speed * multiplier;        
    }
}
