public static ObjectClass FromXProxy(LibraryX.ObjectClassX proxy, ITexturePool texturePool) { if (proxy == null) { return(null); } return(new ObjectClass(proxy, texturePool)); }
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)); } }
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)); } } }
//private Guid _textureId; public TileResourceCollection(int tileWidth, int tileHeight, TilePool pool, ITexturePool texturePool) { _pool = pool; _texturePool = texturePool; TileWidth = tileWidth; TileHeight = tileHeight; _locations = new Dictionary <Guid, TileCoord>(); _openLocations = new List <TileCoord>(); _tileSource = new TextureResource(TileWidth * _initFactor, TileHeight * _initFactor); _texturePool.AddResource(_tileSource); for (int x = 0; x < _initFactor; x++) { for (int y = 0; y < _initFactor; y++) { _openLocations.Add(new TileCoord(x, y)); } } }
public void AddPool(Guid libraryUid, ITexturePool pool) { if (libraryUid == Guid.Empty) { throw new ArgumentException("Library UID must be non-empty."); } if (_pools.ContainsKey(libraryUid)) { throw new ArgumentException("A pool with the given UID has already been added."); } _pools.Add(libraryUid, pool); if (_pools.Count == 1) { _default = libraryUid; } //pool.PoolAdded += HandlePoolAdded; //pool.PoolRemoved += HandlePoolRemoved; }
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); }
public static ObjectClass FromXProxy(LibraryX.ObjectClassX proxy, ITexturePool texturePool) { if (proxy == null) return null; return new ObjectClass(proxy, texturePool); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { ReleaseAll(); SourcePool = null; GraphicsDevice = null; } _disposed = true; } }
public void AddPool(Guid libraryUid, ITexturePool pool) { if (libraryUid == Guid.Empty) throw new ArgumentException("Library UID must be non-empty."); if (_pools.ContainsKey(libraryUid)) throw new ArgumentException("A pool with the given UID has already been added."); _pools.Add(libraryUid, pool); if (_pools.Count == 1) _default = libraryUid; //pool.PoolAdded += HandlePoolAdded; //pool.PoolRemoved += HandlePoolRemoved; }