Esempio n. 1
0
            public Sequence(XNode node)
            {
                XNodeAttributes attr = new XNodeAttributes(node);

                Name = attr.AsString("Name");
                Fps  = attr.AsInt32("Fps", 1);
                Loop = attr.AsBoolean("Loop", false);

                string sequence = attr.AsString("ImageSequence");
                int    start    = attr.AsInt32("Start", 0);
                int    end      = attr.AsInt32("End", 0);

                List <PartialTexture2D> list = new List <PartialTexture2D>();

                for (int idx = start; idx <= end; ++idx)
                {
                    PartialTexture2D texture = ContentLoader.Current.Load <PartialTexture2D>(sequence.Replace("*", idx.ToString()));

                    if (idx > start)
                    {
                        if (texture.Width != list[0].Width || texture.Height != list[0].Height)
                        {
                            throw new InvalidDataException("Sprite must have same size frames.");
                        }
                    }

                    list.Add(texture);
                }

                Images = list.AsReadOnly();
            }
Esempio n. 2
0
        void ParseProperties(XNode node)
        {
            XNodeAttributes attr = new XNodeAttributes(node);

            Name             = attr.AsString("Name");
            Guid             = attr.AsString("Guid");
            TilesetLineWidth = attr.AsInt32("TilesetLineWidth", 8);

            TileSize = UnitSize = attr.AsInt32("UnitSize", TileSize);
        }
Esempio n. 3
0
        public static VectorLayerDefinition FromNode(XNode node)
        {
            XNodeAttributes attr = new XNodeAttributes(node);

            return(new VectorLayerDefinition()
            {
                Selected = attr.AsBoolean("Selected"),
                Name = attr.AsString("Name", "Vector Layer"),
                HorizontalSpeed = attr.AsInt32("HorizontalSpeed", 100),
                VerticalSpeed = attr.AsInt32("VerticalSpeed", 100)
            });
        }
Esempio n. 4
0
        public static TiledLayerDefinition FromNode(XNode node)
        {
            XNodeAttributes attr = new XNodeAttributes(node);

            return(new TiledLayerDefinition()
            {
                Selected = attr.AsBoolean("Selected"),
                Name = attr.AsString("Name", "Tiled Layer"),
                HorizontalSpeed = attr.AsInt32("HorizontalSpeed", 100),
                VerticalSpeed = attr.AsInt32("VerticalSpeed", 100),
                Width = attr.AsInt32("Width", 128),
                Height = attr.AsInt32("Height", 128),
                TiledWidth = attr.AsBoolean("TiledWidth", false),
                TiledHeight = attr.AsBoolean("TiledHeight", false),
                Tileset = attr.AsString("Tileset")
            });
        }