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

            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 (IDirectionElement direction in 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[(Direction)Enum.Parse(typeof(Direction), direction.Value, false)] = animDef;
            }

            return definition;
        }
        public DirectionalAnimatedSprite(DirectionalAnimatedSpriteDefinition definition, SpriteInfo spriteInfo)
            : base(spriteInfo)
        {
            _definition = definition;

            _anims = new AnimatedSprite[16];
            for (int i = 0; i < 16; i++)
                if (_definition[(Direction)i] != null)
                    _anims[i] = new AnimatedSprite(_definition[(Direction)i], SpriteInfo);
        }
 public DirectionalAnimatedSprite(DirectionalAnimatedSpriteDefinition definition)
     : this(definition, new SpriteInfo())
 {
 }