Nez.Portable/PipelineRuntime/Tiled/TiledMap.cs
/// <summary>
/// converts from world to tile position for isometric map clamping to the tilemap bounds
/// </summary>
/// <returns>The to tile position.</returns>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
converts from world to tile position for isometric map clamping to the tilemap bounds
converts from world to tile position for isometric map clamping to the tilemap bounds
public Point isometricWorldToTilePosition(float x, float y, bool clampToTilemapBounds = true)
        {
            x -= (height - 1) * tileWidth / 2;
            var tileX = Mathf.fastFloorToInt((y / tileHeight) + (x / tileWidth));
            var tileY = Mathf.fastFloorToInt((-x / tileWidth) + (y / tileHeight));
            if (!clampToTilemapBounds)
                return new Point(tileX, tileY);
            return new Point(Mathf.clamp(tileX, 0, width - 1), Mathf.clamp(tileY, 0, height - 1));
        }
public Point isometricWorldToTilePosition ( float x , float y , bool clampToTilemapBounds = true ) { x -= ( height - 1 ) * tileWidth / 2 ; var tileX = Mathf . fastFloorToInt ( ( y / tileHeight ) + ( x / tileWidth ) ) ; var tileY = Mathf . fastFloorToInt ( ( - x / tileWidth ) + ( y / tileHeight ) ) ; if ( ! clampToTilemapBounds ) return new Point ( tileX , tileY ) ; return new Point ( Mathf . clamp ( tileX , 0 , width - 1 ) , Mathf . clamp ( tileY , 0 , height - 1 ) ) ; }
converts from world to tile position for isometric map clamping to the tilemap bounds
converts from world to tile position for isometric map clamping to the tilemap bounds
The to tile position.
The to tile position .
x
float
The x coordinate.
The x coordinate .
y
float
The y coordinate.
The y coordinate .
clampToTilemapBounds
bool