Nez.Portable/PipelineRuntime/Tiled/TiledIsometricTiledLayer.cs
/// <summary>
/// Finds the largest bounding rect around tiles between startX and endX, starting at startY and going
/// down as far as possible
/// </summary>
/// <returns>The bounds rect.</returns>
/// <param name="startX">Start x.</param>
/// <param name="endX">End x.</param>
/// <param name="startY">Start y.</param>
/// <param name="checkedIndexes">Checked indexes.</param>
Finds the largest bounding rect around tiles between startX and endX, starting at startY and going
down as far as possible
Finds the largest bounding rect around tiles between startX and endX starting at startY and going down as far as possible
public Rectangle findBoundsRect(int startX, int endX, int startY, bool?[] checkedIndexes)
        {
            var index = -1;
            for (var y = startY + 1; y < tiledMap.height; y++)
            {
                for (var x = startX; x < endX; x++)
                {
                    index = y * tiledMap.width + x;
                    var tile = getTile(x, y);
                    if (tile == null || checkedIndexes[index] == true)
                    {
                        for (var _x = startX; _x < x; _x++)
                        {
                            index = y * tiledMap.width + _x;
                            checkedIndexes[index] = false;
                        }
                        return new Rectangle(
                            startX * tiledMap.tileWidth,
                            startY * tiledMap.tileHeight,
                            (endX - startX) * tiledMap.tileWidth,
                            (y - startY) * tiledMap.tileHeight);
                    }
                    checkedIndexes[index] = true;
                }
            }
            return new Rectangle(
                startX * tiledMap.tileWidth,
                startY * tiledMap.tileHeight,
                (endX - startX) * tiledMap.tileWidth,
                (tiledMap.height - startY) * tiledMap.tileHeight);
        }
public Rectangle findBoundsRect ( int startX , int endX , int startY , bool ? [ ] checkedIndexes ) { var index = - 1 ; for ( var y = startY + 1 ; y < tiledMap . height ; y ++ ) { for ( var x = startX ; x < endX ; x ++ ) { index = y * tiledMap . width + x ; var tile = getTile ( x , y ) ; if ( tile == null || checkedIndexes [ index ] == true ) { for ( var _x = startX ; _x < x ; _x ++ ) { index = y * tiledMap . width + _x ; checkedIndexes [ index ] = false ; } return new Rectangle ( startX * tiledMap . tileWidth , startY * tiledMap . tileHeight , ( endX - startX ) * tiledMap . tileWidth , ( y - startY ) * tiledMap . tileHeight ) ; } checkedIndexes [ index ] = true ; } } return new Rectangle ( startX * tiledMap . tileWidth , startY * tiledMap . tileHeight , ( endX - startX ) * tiledMap . tileWidth , ( tiledMap . height - startY ) * tiledMap . tileHeight ) ; }
Finds the largest bounding rect around tiles between startX and endX, starting at startY and going
down as far as possible
Finds the largest bounding rect around tiles between startX and endX starting at startY and going down as far as possible
// Set everything we've visited so far in this row to false again because it won't be included in the rectangle and should be checked again
The bounds rect.
The bounds rect .
startX
int
None
endX
int
None
startY
int
None
checkedIndexes
bool?[]
None