public static List <FloorCell> getNeighbourListOfType(FloorCell tile, Dictionary <Vector3Int, FloorCell> FloorCellDictionary, FloorCell.FloorCellType floorCellType, int distance = 1) { // Cogemos los vecinos List <FloorCell> neigbours = new List <FloorCell>(); for (int x = -distance; x < distance + 1; x++) { for (int y = -distance; y < distance + 1; y++) { // Cogemos vecinos en cruz if (FloorCellDictionary.ContainsKey(new Vector3Int(x, 0, y) + tile.position) && Mathf.Abs(x) + Mathf.Abs(y) == 1) { FloorCell nei = FloorCellDictionary[new Vector3Int(x, 0, y) + tile.position]; if (nei.type == floorCellType) { neigbours.Add(nei); } } } } return(neigbours); }
public static bool hasNeighbourCellsOfType(FloorCell tile, Dictionary <Vector3Int, FloorCell> FloorCellDictionary, FloorCell.FloorCellType type, int distance = 1) { bool hasNeiCells = false; List <FloorCell> neigbours = new List <FloorCell>(); neigbours = getNeighbourList(tile, FloorCellDictionary); foreach (FloorCell nei in neigbours) { if (nei.type == type) { hasNeiCells = true; break; } } return(hasNeiCells); }