Exemplo n.º 1
0
 /// <summary> Tries to spread the given <paramref name="tile"/> to the given <paramref name="x"/> and <paramref name="y"/> positions. </summary>
 /// <param name="tilemap"> The tilemap. </param>
 /// <param name="tile"> The tile that is being spread. </param>
 /// <param name="x"> The x position that is being spread to. </param>
 /// <param name="y"> The y position that is being spread to. </param>
 /// <returns> True if the tile spread, otherwise; false. </returns>
 private bool trySpreadToTile(BaseTilemap <FloorTileData> tilemap, Tile <FloorTileData> tile, int x, int y)
 {
     // If the tile is the spreadable material, can be placed, and the random roll was successful, spread the grass and return true.
     if (tilemap.IsTile(x, y, spreadableTile) && tile.CanPlace(tilemap, x, y) && Random.value <= spreadChance)
     {
         tilemap.SetTile(x, y, tile);
         return(true);
     }
     // Otherwise; return false as no grass was spread.
     else
     {
         return(false);
     }
 }