ToXmlProxyX() public static method

public static ToXmlProxyX ( Property property ) : CommonX.PropertyX
property Property
return Treefrog.Framework.Model.Proxy.CommonX.PropertyX
Exemplo n.º 1
0
        public static LevelX.ObjectLayerX ToXmlProxyX(ObjectLayer layer)
        {
            if (layer == null)
            {
                return(null);
            }

            List <LevelX.ObjectInstanceX> objs = new List <LevelX.ObjectInstanceX>();

            foreach (ObjectInstance inst in layer.Objects)
            {
                objs.Add(ObjectInstance.ToXProxy(inst));
            }

            List <CommonX.PropertyX> props = new List <CommonX.PropertyX>();

            foreach (Property prop in layer.PropertyManager.CustomProperties)
            {
                props.Add(Property.ToXmlProxyX(prop));
            }

            return(new LevelX.ObjectLayerX()
            {
                Name = layer.Name,
                Opacity = layer.Opacity,
                Visible = layer.IsVisible,
                RasterMode = layer.RasterMode,
                GridColor = layer.GridColor.ToArgbHex(),
                GridWidth = layer.GridWidth,
                GridHeight = layer.GridHeight,
                Objects = objs.Count > 0 ? objs : null,
                Properties = props.Count > 0 ? props : null,
            });
        }
Exemplo n.º 2
0
        public static LibraryX.TilePoolX ToXProxy(TilePool pool)
        {
            if (pool == null)
            {
                return(null);
            }

            List <LibraryX.TileDefX> tiledefs = new List <LibraryX.TileDefX>();

            foreach (Tile tile in pool._tiles)
            {
                tiledefs.Add(TileResourceCollection.ToXmlProxyX(tile));
            }

            List <CommonX.PropertyX> props = new List <CommonX.PropertyX>();

            foreach (Property prop in pool.PropertyManager.CustomProperties)
            {
                props.Add(Property.ToXmlProxyX(prop));
            }

            return(new LibraryX.TilePoolX()
            {
                Uid = pool.Uid,
                Name = pool.Name,
                Texture = pool.Tiles.TextureId,
                TileWidth = pool.TileWidth,
                TileHeight = pool.TileHeight,
                TileDefinitions = tiledefs.Count > 0 ? tiledefs : null,
                Properties = props.Count > 0 ? props : null,
            });
        }
Exemplo n.º 3
0
        public static LibraryX.ObjectClassX ToXProxy(ObjectClass objClass)
        {
            if (objClass == null)
            {
                return(null);
            }

            List <CommonX.PropertyX> props = new List <CommonX.PropertyX>();

            foreach (Property prop in objClass.PropertyManager.CustomProperties)
            {
                props.Add(Property.ToXmlProxyX(prop));
            }

            return(new LibraryX.ObjectClassX()
            {
                Uid = objClass.Uid,
                Name = objClass.Name,
                Texture = objClass._image != null ? objClass._image.Uid : Guid.Empty,
                ImageBounds = objClass._imageBounds,
                MaskBounds = objClass._maskBounds,
                Origin = objClass._origin,
                Properties = props.Count > 0 ? props : null,
            });
        }
Exemplo n.º 4
0
        public static LevelX.MultiTileGridLayerX ToXmlProxyX(MultiTileGridLayer layer)
        {
            if (layer == null)
            {
                return(null);
            }

            const int blockSize = 4;

            int xLimit = (layer.TilesWide + blockSize - 1) / blockSize;
            int yLimit = (layer.TilesHigh + blockSize - 1) / blockSize;

            List <CommonX.TileBlockX> blocks = new List <CommonX.TileBlockX>();

            for (int y = 0; y < yLimit; y++)
            {
                for (int x = 0; x < xLimit; x++)
                {
                    string data = layer.BuildTileBlockString(x * blockSize, y * blockSize, blockSize, blockSize);
                    if (!string.IsNullOrEmpty(data))
                    {
                        blocks.Add(new CommonX.TileBlockX()
                        {
                            X    = x * blockSize,
                            Y    = y * blockSize,
                            Data = data,
                        });
                    }
                }
            }

            List <CommonX.PropertyX> props = new List <CommonX.PropertyX>();

            foreach (Property prop in layer.PropertyManager.CustomProperties)
            {
                props.Add(Property.ToXmlProxyX(prop));
            }

            return(new LevelX.MultiTileGridLayerX()
            {
                Name = layer.Name,
                Opacity = layer.Opacity,
                Visible = layer.IsVisible,
                RasterMode = layer.RasterMode,
                GridColor = layer.GridColor.ToArgbHex(),
                TileWidth = layer.TileWidth,
                TileHeight = layer.TileHeight,
                Blocks = blocks.Count > 0 ? blocks : null,
                Properties = props.Count > 0 ? props : null,
            });
        }
Exemplo n.º 5
0
        public static LibraryX.TileDefX ToXmlProxyX(Tile tile)
        {
            if (tile == null)
            {
                return(null);
            }

            List <CommonX.PropertyX> props = new List <CommonX.PropertyX>();

            foreach (Property prop in tile.PropertyManager.CustomProperties)
            {
                props.Add(Property.ToXmlProxyX(prop));
            }

            TileCoord loc = tile.Pool.Tiles.GetTileLocation(tile.Uid);

            return(new LibraryX.TileDefX()
            {
                Uid = tile.Uid,
                Location = loc.X + "," + loc.Y,
                Properties = props.Count > 0 ? props : null,
            });
        }
Exemplo n.º 6
0
        public static LevelX.ObjectInstanceX ToXProxy(ObjectInstance inst)
        {
            if (inst == null)
            {
                return(null);
            }

            List <CommonX.PropertyX> props = new List <CommonX.PropertyX>();

            foreach (Property prop in inst.PropertyManager.CustomProperties)
            {
                props.Add(Property.ToXmlProxyX(prop));
            }

            return(new LevelX.ObjectInstanceX()
            {
                Uid = inst.Uid,
                Class = inst.ObjectClass.Uid,
                X = inst.X,
                Y = inst.Y,
                Rotation = MathEx.RadToDeg(inst.Rotation),
                Properties = (props.Count > 0) ? props : null,
            });
        }