FromXmlProxy() public static method

public static FromXmlProxy ( CommonX proxy ) : Property
proxy Treefrog.Framework.Model.Proxy.CommonX
return Property
示例#1
0
        public MultiTileGridLayer(LevelX.MultiTileGridLayerX proxy, Level level, Dictionary <int, Guid> tileIndex)
            : base(proxy.Name, proxy.TileWidth, proxy.TileHeight, level)
        {
            _tiles = new TileStack[TilesHigh, TilesWide];

            Opacity    = proxy.Opacity;
            IsVisible  = proxy.Visible;
            RasterMode = proxy.RasterMode;
            GridColor  = Color.ParseArgbHex(proxy.GridColor);
            Level      = level;

            if (proxy.Blocks != null)
            {
                foreach (var blockProxy in proxy.Blocks)
                {
                    ParseTileBlockString(blockProxy.Data);
                }
            }

            if (proxy.Properties != null)
            {
                foreach (var propertyProxy in proxy.Properties)
                {
                    PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
                }
            }
        }
示例#2
0
        public ObjectLayer(LevelX.ObjectLayerX proxy, Level level)
            : this(proxy.Name, level)
        {
            Opacity    = proxy.Opacity;
            IsVisible  = proxy.Visible;
            RasterMode = proxy.RasterMode;
            GridColor  = Color.ParseArgbHex(proxy.GridColor);
            GridWidth  = proxy.GridWidth;
            GridHeight = proxy.GridHeight;
            Level      = level;

            IResourceCollection <ObjectPool> pools = Level.Project.ObjectPoolManager.Pools;

            foreach (var objProxy in proxy.Objects)
            {
                ObjectInstance inst = ObjectInstance.FromXProxy(objProxy, Level.Project.ObjectPoolManager);
                if (inst != null)
                {
                    AddObject(inst);
                }
            }

            if (proxy.Properties != null)
            {
                foreach (var propertyProxy in proxy.Properties)
                {
                    PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
                }
            }
        }
示例#3
0
        private ObjectInstance(LevelX.ObjectInstanceX proxy, ObjectClass objClass)
            : this(objClass, proxy.X, proxy.Y)
        {
            _uid      = proxy.Uid;
            _rotation = MathEx.DegToRad(proxy.Rotation);

            if (proxy.Properties != null)
            {
                foreach (var propertyProxy in proxy.Properties)
                {
                    PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
                }
            }

            UpdateBounds();
        }
示例#4
0
        private void Initialize(LevelX proxy, Project project)
        {
            if (proxy.PropertyGroup != null)
            {
                Extra = new List <XmlElement>(proxy.PropertyGroup.Extra ?? new XmlElement[0]);
            }

            _project       = project;
            _x             = proxy.OriginX;
            _y             = proxy.OriginY;
            _width         = Math.Max(1, proxy.Width);
            _height        = Math.Max(1, proxy.Height);
            _indexSequence = proxy.TileIndex.Sequence;

            Dictionary <int, Guid> tileIndex = new Dictionary <int, Guid>();

            foreach (var entry in proxy.TileIndex.Entries)
            {
                _localTileIndex.Add(entry.Id, entry.Uid);
                tileIndex.Add(entry.Id, entry.Uid);

                if (entry.Id >= _indexSequence)
                {
                    _indexSequence = entry.Id + 1;
                }
            }

            foreach (LevelX.LayerX layerProxy in proxy.Layers)
            {
                if (layerProxy is LevelX.MultiTileGridLayerX)
                {
                    Layers.Add(new MultiTileGridLayer(layerProxy as LevelX.MultiTileGridLayerX, this, tileIndex));
                }
                else if (layerProxy is LevelX.ObjectLayerX)
                {
                    Layers.Add(new ObjectLayer(layerProxy as LevelX.ObjectLayerX, this));
                }
            }

            if (proxy.Properties != null)
            {
                foreach (var propertyProxy in proxy.Properties)
                {
                    PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
                }
            }
        }
示例#5
0
        private ObjectClass(LibraryX.ObjectClassX proxy, ITexturePool texturePool)
            : this(proxy.Name)
        {
            _uid         = proxy.Uid;
            _image       = texturePool.GetResource(proxy.Texture);
            _imageBounds = proxy.ImageBounds;
            _maskBounds  = proxy.MaskBounds;
            _origin      = proxy.Origin;

            if (proxy.Properties != null)
            {
                foreach (var propertyProxy in proxy.Properties)
                {
                    PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
                }
            }
        }
示例#6
0
        public static Tile FromXmlProxy(LibraryX.TileDefX proxy, TileResourceCollection tileCollection)
        {
            if (proxy == null)
            {
                return(null);
            }

            string[] loc = proxy.Location.Split(new char[] { ',' });
            if (loc.Length != 2)
            {
                throw new Exception("Malformed location: " + proxy.Location);
            }

            int x = Convert.ToInt32(loc[0]);
            int y = Convert.ToInt32(loc[1]);

            if (x < 0 || y < 0)
            {
                throw new Exception("Invalid location: " + proxy.Location);
            }

            TileCoord coord = new TileCoord(x, y);
            Tile      tile  = new PhysicalTile(proxy.Uid)
            {
                Pool = tileCollection._pool,
            };

            if (proxy.Properties != null)
            {
                foreach (var propertyProxy in proxy.Properties)
                {
                    tile.PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
                }
            }

            tileCollection._locations[tile.Uid] = coord;
            tileCollection.Add(tile);

            return(tile);
        }
示例#7
0
        private TilePool(LibraryX.TilePoolX proxy, TilePoolManager manager)
            : this()
        {
            _uid  = proxy.Uid;
            _name = new ResourceName(this, proxy.Name);

            Tiles                   = TileResourceCollection.FromXmlProxy(proxy, this, manager.TexturePool);
            Tiles.Modified         += (s, e) => OnModified(EventArgs.Empty);
            Tiles.ResourceAdded    += (s, e) => OnTileAdded(new TileEventArgs(e.Resource));
            Tiles.ResourceRemoved  += (s, e) => OnTileRemoved(new TileEventArgs(e.Resource));
            Tiles.ResourceModified += (s, e) => OnTileModified(new TileEventArgs(e.Resource));

            manager.Pools.Add(this);

            if (proxy.Properties != null)
            {
                foreach (var propertyProxy in proxy.Properties)
                {
                    PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
                }
            }
        }