コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
ファイル: CounterElement.cs プロジェクト: jaquadro/Amphibian
        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;
        }