Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// This function calculates the bitmask value for the tile, allowing us to assign is a tile
- /// </summary>
- /// <param X pos of tile on grid="x"></param>
- /// <param y pos of tile on grid="z"></param>
- /// <returns></returns>
- private int calculateTileBitmaskValue(int x,int z)
- {
- //Begin by assuming tile is water
- int bitmaskValue = 15;
- float tileHeight = terrainHeights[x, z];
- if (getIsLand(tileHeight))
- {
- //The tile is land, let's check surrounding neighbours.
- bool north_tile = getIsLand(terrainHeights[x, z - 1]);
- bool east_tile = getIsLand(terrainHeights[x+1, z]);
- bool west_tile = getIsLand(terrainHeights[x-1, z]);
- bool south_tile = getIsLand(terrainHeights[x, z + 1]);
- //Calculate our bitmask value from our boolean values for each direction:
- bitmaskValue = ((1 * Convert.ToInt32(north_tile)) + (2 * Convert.ToInt32(west_tile))
- + (4 * Convert.ToInt32(east_tile)) + (8 * Convert.ToInt32(south_tile)));
- }
- return bitmaskValue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement