예제 #1
0
 internal AbstractTiledLayer(XElement xLayer, ITiledLayer parent)
     : base(xLayer)
 {
     Parent = parent;
 }
예제 #2
0
 internal TiledGroup(XElement xGroup, ITiledLayer parent)
     : base(xGroup, parent)
 {
 }
예제 #3
0
        private void Load()
        {
            _xmlDoc.Load(FullFilename);
            _rootElement = _xmlDoc["map"];

            // map header info
            Version      = _rootElement.GetAttribute("version");
            Orientation  = (TiledMapOrientation)Enum.Parse(typeof(TiledMapOrientation), _rootElement.GetAttribute("orientation"), true);
            RenderOrder  = (TiledRenderOrder)Enum.Parse(typeof(TiledRenderOrder), _rootElement.GetAttribute("renderorder").Replace("-", ""), true);
            Columns      = int.Parse(_rootElement.GetAttribute("width"));
            Rows         = int.Parse(_rootElement.GetAttribute("height"));
            TileSize     = new Size(int.Parse(_rootElement.GetAttribute("tilewidth")), int.Parse(_rootElement.GetAttribute("tileheight")));
            NextObjectId = int.Parse(_rootElement.GetAttribute("nextobjectid"));

            if (_rootElement.HasAttribute("backgroundcolor"))
            {
                BackgroundColor = new Color(_rootElement.GetAttribute("backgroundcolor"));
            }

            if (Orientation == TiledMapOrientation.Hexagonal)
            {
                HexSideLength = int.Parse(_rootElement.GetAttribute("hexsidelength"));
            }

            if (Orientation == TiledMapOrientation.Hexagonal || Orientation == TiledMapOrientation.Staggered)
            {
                StaggerAxis  = (TiledStaggerAxis)Enum.Parse(typeof(TiledStaggerAxis), _rootElement.GetAttribute("staggeraxis"), true);
                StaggerIndex = (TiledStaggerIndex)Enum.Parse(typeof(TiledStaggerIndex), _rootElement.GetAttribute("staggerindex"), true);
            }

            // properties
            XmlElement element = _rootElement["properties"];

            if (element != null)
            {
                foreach (XmlElement propertyElement in element)
                {
                    Properties.Add(propertyElement.GetAttribute("name"), new TiledProperty(propertyElement));
                }
            }

            // tilesets
            foreach (XmlElement tilesetElement in _rootElement.GetElementsByTagName("tileset"))
            {
                TiledTileset tileset = !tilesetElement.HasAttribute("source") ? new TiledTileset(Path, tilesetElement) : new TiledTileset(Path + tilesetElement.GetAttribute("source"), int.Parse(tilesetElement.GetAttribute("firstgid")));
                Tilesets.Add(tileset);
            }

            // layers
            foreach (XmlElement layerElement in _rootElement)
            {
                ITiledLayer layer = null;
                switch (layerElement.Name)
                {
                case "layer":
                    layer = new TiledTileLayer(layerElement);
                    break;

                case "objectgroup":
                    layer = new TiledObjectLayer(layerElement);
                    break;

                case "imagelayer":
                    layer = new TiledImageLayer(Path, layerElement);
                    break;

                default:
                    break;
                }

                if (layer != null)
                {
                    Layers.Add(layer);
                }
            }
        }
예제 #4
0
 internal TiledImageLayer(XElement xImageLayer, ITiledLayer parent)
     : base(xImageLayer, parent)
 {
 }
예제 #5
0
 internal TiledLayer(XElement xLayer, ITiledLayer parent)
     : base(xLayer, parent)
 {
 }