Пример #1
0
 protected override void ReadXml(XElement xWangCorner)
 {
     Name        = (string)xWangCorner.Attribute("name");
     Color       = new TiledColor((string)xWangCorner.Attribute("color"));
     Tile        = (int)xWangCorner.Attribute("tile");
     Probability = (float)xWangCorner.Attribute("probability");
 }
Пример #2
0
        protected override void ReadXml(XElement xImage)
        {
            Format      = (string)xImage.Attribute("format");
            Source      = (string)xImage.Attribute("source");
            Transparent = new TiledColor((string)xImage.Attribute("trans"));
            Width       = (int)xImage.Attribute("width");
            Height      = (int)xImage.Attribute("height");
            var data = xImage.Element("data");

            if (data != null)
            {
                EmbeddedData = new TiledData(data);
            }
        }
Пример #3
0
        protected override void ReadXml(XElement xText)
        {
            Text       = xText.Value;
            FontFamily = (string)xText.Attribute("fontfamily") ?? "sans-serif";
            PixelSize  = (int?)xText.Attribute("pixelsize") ?? 16;
            Wrap       = ((int?)xText.Attribute("wrap") ?? 0) == 1;
            Color      = new TiledColor((string)xText.Attribute("color"));
            Bold       = ((int?)xText.Attribute("bold") ?? 0) == 1;
            Italic     = ((int?)xText.Attribute("italic") ?? 0) == 1;
            Underline  = ((int?)xText.Attribute("underline") ?? 0) == 1;
            StrikeOut  = ((int?)xText.Attribute("strikeout") ?? 0) == 1;
            Kerning    = ((int?)xText.Attribute("kerning") ?? 0) == 1;
            var halign = (string)xText.Attribute("halign");

            HAlign = halign == null ? HorizontalAlignment.Left : HorizontalAlignmentParser[halign];
            var valign = (string)xText.Attribute("valign");

            VAlign = valign == null ? VerticalAlignment.Top : VerticalAlignmentParser[valign];
        }
Пример #4
0
        protected override void ReadXml(XElement xGroup)
        {
            Name     = (string)xGroup.Attribute("name");
            Color    = new TiledColor((string)xGroup.Attribute("color"));
            _opacity = ((float?)xGroup.Attribute("opacity")) ?? 1f;

            var visible = xGroup.Attribute("visible");

            _visible = visible == null ? true : (int)visible == 1;

            _offsetX = ((int?)xGroup.Attribute("offsetx")) ?? 0;
            _offsetY = ((int?)xGroup.Attribute("offsety")) ?? 0;
            var drawOrder = (string)xGroup.Attribute("draworder");

            DrawOrder = drawOrder == null ? DrawOrderType.TopDown : DrawOrderParser[drawOrder];

            Properties = ReadProperties(xGroup.Element("properties"));

            foreach (var obj in xGroup.Elements("object"))
            {
                Objects.Add(new TiledObject(obj));
            }
        }
Пример #5
0
        protected override void ReadXml(XElement xMap)
        {
            Version      = (string)xMap.Attribute("version");
            TiledVersion = (string)xMap.Attribute("tiledversion");

            var orientation = (string)xMap.Attribute("orientation");

            if (orientation != null)
            {
                Orientation = OrientationParser[orientation];
            }

            var renderOrder = (string)xMap.Attribute("renderorder");

            if (renderOrder != null)
            {
                RenderOrder = RenderOrderParser[renderOrder];
            }

            Width         = (int)xMap.Attribute("width");
            Height        = (int)xMap.Attribute("height");
            TileWidth     = (int)xMap.Attribute("tilewidth");
            TileHeight    = (int)xMap.Attribute("tileheight");
            HexSideLength = (int?)xMap.Attribute("hexsidelength");

            var axis = (string)xMap.Attribute("staggeraxis");

            if (axis != null)
            {
                StaggerAxis = AxisParser[axis];
            }

            var staggerIndex = (string)xMap.Attribute("staggerindex");

            if (staggerIndex != null)
            {
                StaggerIndex = StaggerIndexParser[staggerIndex];
            }

            BackgroundColor = new TiledColor((string)xMap.Attribute("backgroundcolor"));
            Infinite        = ((int)xMap.Attribute("infinite")) == 0 ? false : true;
            NextObjectId    = (int?)xMap.Attribute("nextobjectid");

            Properties = ReadProperties(xMap.Element("properties"));

            foreach (var tileset in xMap.Elements("tileset"))
            {
                Tilesets.Add(new TiledTileset(tileset));
            }

            foreach (var xLayer in xMap.Elements("layer"))
            {
                Layers.Add(new TiledLayer(xLayer));
            }

            foreach (var xObjectGroup in xMap.Elements("objectgroup"))
            {
                Objects.Add(new TiledObjectGroup(xObjectGroup));
            }

            foreach (var xImageLayer in xMap.Elements("imagelayer"))
            {
                Images.Add(new TiledImageLayer(xImageLayer));
            }

            foreach (var xGroup in xMap.Elements("group"))
            {
                Groups.Add(new TiledGroup(xGroup));
            }
        }