Coin CreateCoin(int x, int y) { if (y == 0) { return(null); } if (!PRNG.Bool(Def.CoinDensity)) { return(null); } var cell = new Cell(x, y); if (cell == Exit.Cell) { return(null); } // if (GetBlock(cell)) return null; // if (!GetBlock(cell + Vector2Int.up)) return null; if (Gems != null && GetGem(cell)) { return(null); } return(Instantiate(CoinPrefab, transform).Init(cell)); }
public static bool[,] Smooth(this bool[,] array, PRNG prng, int minNeighborCountToAdd = 4, int maxNeighborCountToRemove = 4, float probabilityToAdd = 1f, float probabilityToRemove = 1f) { bool[,] smoothed = (bool[, ])array.Clone(); for (int x = 0; x < smoothed.GetLength(0); x++) { for (int y = 0; y < smoothed.GetLength(1); y++) { int neighbourWallTiles = array.GetSurroundingWallCount(x, y); if (neighbourWallTiles > minNeighborCountToAdd && prng.Bool(probabilityToAdd)) { smoothed[x, y] = true; } else if (neighbourWallTiles < maxNeighborCountToRemove && prng.Bool(probabilityToRemove)) { smoothed[x, y] = false; } } } return(smoothed); }