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 AnimatedSpriteDefinition BuildDefinition(ContentManager contentManager) { AnimatedSpriteDefinition definition = new AnimatedSpriteDefinition(); 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 (IFrameElement frame in Animation.Frames) { if (spriteDefs.ContainsKey(frame.Sprite)) definition.AddSprite(spriteDefs[frame.Sprite], frame.Duration); } if (Animation.Repeat < 0) definition.RepeatIndefinitely = true; else definition.RepeatLimit = Animation.Repeat; return definition; }
public StaticSpriteDefinition BuildDefinition(ContentManager contentManager) { StaticSpriteDefinition definition = new StaticSpriteDefinition(); ISpriteElement sprite = Sprites.Sprites[0]; definition.Load(contentManager, Sprites.Source, new Rectangle( sprite.X, sprite.Y, sprite.Width, sprite.Height)); definition.Origin = new Vector2(sprite.OriginX, sprite.OriginY); return definition; }
public CounterDefinition BuildDefinition(ContentManager contentManager) { CounterDefinition definition = new CounterDefinition(); foreach (ISpriteElement sprite in Sprites.Sprites) { if (!CounterDefinition.DigitIndex.ContainsKey(sprite.Name)) continue; 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); definition.DigitFrames[CounterDefinition.DigitIndex[sprite.Name]] = spriteDef; } return definition; }
public StaticSprite(StaticSpriteDefinition definition, SpriteInfo spriteInfo) : base(spriteInfo) { _definition = definition; }
public StaticSprite(StaticSpriteDefinition definition) { _definition = definition; }
public void AddSprite(StaticSpriteDefinition sprite, float duration) { _frames.Add(new AnimatedSpriteDefinition.SpriteFrame(sprite, duration)); }
public SpriteFrame(StaticSpriteDefinition frame, float duration) { Frame = frame; Duration = duration; }