private void ExpandTexture() { int width = _tileSource.Width; int height = _tileSource.Height; if (width == height) { width *= 2; } else { height *= 2; } TextureResource newTex = new TextureResource(width, height); newTex.Set(_tileSource, new Point(0, 0)); int factorX = newTex.Width / TileWidth; int factorY = newTex.Height / TileHeight; int threshX = _tileSource.Width / TileWidth; int threshY = _tileSource.Height / TileHeight; for (int y = 0; y < factorY; y++) { for (int x = 0; x < factorX; x++) { if (x >= threshX || y >= threshY) { _openLocations.Add(new TileCoord(x, y)); } } } _texturePool.RemoveResource(_tileSource.Uid); _tileSource = newTex; _texturePool.AddResource(_tileSource); }
//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)); } } }