internal NamedTileKey(NamedTileIndex index, String name, Texture2dArea tile) : base(tile) { //Inits moved here because parameters need to be passed. InitializeIndex(index); InitializeKey(name); }
internal ColumnKey(ColumnIndex index, Int32 column, Texture2dArea tile) : base(tile) { //Inits moved here because parameters need to be passed. InitializeIndex(index); InitializeKey(column); }
//TODO: Add support for optional source area and padding. public void CreateColumnIndex(Int32 columns) { //TODO: for the moment, we only support a single ColumnIndex. if(ColumnIndex.Count > 0) throw new InvalidOperationException("Only one index supported currently."); if(columns < 1 || columns > Texture.Width) throw new ArgumentOutOfRangeException(); if(Texture.Width % columns != 0) throw new ArgumentOutOfRangeException(); Int32 tileWidth = Texture.Width / columns; Int32 tileHeight = Texture.Height; for(Int32 i = 0; i < columns; i++) { Int32 left = i * tileWidth; Int32 top = 0; Int32 right = left + tileWidth - 1; //zero indexed, so -1. Int32 bottom = tileHeight - 1; //zero indexed, so -1. Texture2dArea area = new Texture2dArea(left, top, right, bottom, Texture.Width, Texture.Height); ColumnIndex.Add(i, area); } }
private void BuildKeyList(Int32 columns) { if(columns < 1 || columns > TiledTexture.Texture.Width) throw new ArgumentOutOfRangeException(); if(TiledTexture.Texture.Width % columns != 0) throw new ArgumentOutOfRangeException(); Int32 tileWidth = TiledTexture.Texture.Width / columns; Int32 tileHeight = TiledTexture.Texture.Height; for(Int32 c = 0; c < columns; c++) { Int32 left = c * tileWidth; Int32 top = 0; Int32 right = left + tileWidth; Int32 bottom = tileHeight; Texture2dArea area = new Texture2dArea(left, top, right, bottom, TiledTexture.Texture.Width, TiledTexture.Texture.Height); ColumnKey key = new ColumnKey(this, c, area); Keys.Add(c, key); } }
private void BuildKeyList(Int32 columns, Int32 rows) { //At least 1 if(columns < 1 || rows < 1) throw new ArgumentOutOfRangeException(); //Can't be greater than number of pixels if(columns > TiledTexture.Texture.Width || rows > TiledTexture.Texture.Height) throw new ArgumentOutOfRangeException(); //Must be evenly divisible if(TiledTexture.Texture.Width % columns != 0 || TiledTexture.Texture.Height % rows != 0) throw new ArgumentOutOfRangeException(); Int32 tileWidth = TiledTexture.Texture.Width / columns; Int32 tileHeight = TiledTexture.Texture.Height / rows; for(Int32 r = 0; r < rows; r++) { for(Int32 c = 0; c < columns; c++) { Int32 left = c * tileWidth; Int32 right = left + tileWidth; Int32 top = r * tileHeight; Int32 bottom = top + tileHeight; Texture2dArea area = new Texture2dArea(left, top, right, bottom, TiledTexture.Texture.Width, TiledTexture.Texture.Height); GridLocation loc = new GridLocation(c, r); GridKey key = new GridKey(this, c, r, area); Keys.Add(loc, key); } } }
private void InitializeTile(Texture2dArea tile) { Tile = tile; }
private void InitializeInternal(Texture2dArea tile) { InitializeTile(tile); }
internal KeyBase(Texture2dArea tile) { InitializeInternal(tile); Initialize(); }