Пример #1
0
        public static TileResourceCollection FromXmlProxy(LibraryX.TilePoolX proxy, TilePool pool, ITexturePool texturePool)
        {
            if (proxy == null)
            {
                return(null);
            }

            TileResourceCollection collection = new TileResourceCollection(proxy.TileWidth, proxy.TileHeight, pool, texturePool);

            texturePool.RemoveResource(collection.TextureId);

            collection._tileSource = texturePool.GetResource(proxy.Texture);

            if (collection._tileSource != null)
            {
                collection._tileSource.Apply(c => {
                    return((c.A == 0) ? Colors.Transparent : c);
                });
            }

            if (proxy.TileDefinitions != null)
            {
                foreach (var tiledef in proxy.TileDefinitions)
                {
                    TileResourceCollection.FromXmlProxy(tiledef, collection);
                }
            }

            if (collection.TextureResource != null)
            {
                collection.RecalculateOpenLocations();
            }

            return(collection);
        }
Пример #2
0
        public Texture2D Resolve(Guid textureId)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("TextureCache");
            }

            if (_device == null || _sourcePool == null)
            {
                return(null);
            }

            Texture2D tex;

            if (_cache.TryGetValue(textureId, out tex) && tex != null)
            {
                return(tex);
            }

            TextureResource resource = _sourcePool.GetResource(textureId);

            if (resource != null)
            {
                tex = resource.CreateTexture(_device);
                _cache.Add(textureId, tex);
            }

            return(tex);
        }
Пример #3
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));
                }
            }
        }
Пример #4
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));
            }
        }