public DirectionalAnimationSetDefinition BuildDefinition(ContentManager contentManager)
        {
            DirectionalAnimationSetDefinition definition = new DirectionalAnimationSetDefinition();

            Dictionary<String, StaticSpriteDefinition> spriteDefs = new Dictionary<string, StaticSpriteDefinition>();
            foreach (ISpriteElement sprite in Sprites.Sprites) {
                StaticSpriteDefinition spriteDef = new StaticSpriteDefinition();
                spriteDef.Load(contentManager, Sprites.Source, new Rectangle(
                    sprite.X, sprite.Y, sprite.Width, sprite.Height));
                spriteDef.Origin = new Vector2(sprite.OriginX, sprite.OriginY);

                spriteDefs[sprite.Name] = spriteDef;
            }

            foreach (IAnimationSetElement animSet in AnimationSets) {
                definition[animSet.Name] = new DirectionalAnimatedSpriteDefinition();

                foreach (IDirectionElement direction in animSet.Directions) {
                    AnimatedSpriteDefinition animDef = new AnimatedSpriteDefinition();
                    foreach (IFrameElement frame in direction.Animation.Frames) {
                        if (spriteDefs.ContainsKey(frame.Sprite))
                            animDef.AddSprite(spriteDefs[frame.Sprite], frame.Duration);
                    }

                    if (direction.Animation.Repeat < 0)
                        animDef.RepeatIndefinitely = true;
                    else
                        animDef.RepeatLimit = direction.Animation.Repeat;

                    definition[animSet.Name][(Direction)Enum.Parse(typeof(Direction), direction.Value, false)] = animDef;
                }
            }

            return definition;
        }
        public DirectionalAnimationSet(DirectionalAnimationSetDefinition definition)
        {
            _definition = definition;

            _anims = new Dictionary<String, AnimatedSprite[]>();
            foreach (String key in _definition.AvailableSets) {
                _anims[key] = new AnimatedSprite[16];
                for (int i = 0; i < 16; i++) {
                    AnimatedSpriteDefinition seqDefinition = _definition[key][(Direction)i];
                    if (seqDefinition != null)
                        _anims[key][i] = new AnimatedSprite(seqDefinition, SpriteInfo);
                }
            }
        }