private void AssertCellIsIsolatedOnSides(Cell cell, IEnumerable<Direction> directions, Map<Cell> map) { foreach (var direction in directions) { Assert.IsTrue(map.GetAdjacentCell(cell, direction) == null || map.GetAdjacentCell(cell, direction).Terrain == TerrainType.Rock); } }
private bool ShouldConsiderRockCell(Cell cell, Direction direction, Map<Cell> map) { Cell adjacentCell; return (map.TryGetAdjacentCell(cell, direction, out adjacentCell) && adjacentCell.Terrain == TerrainType.Rock && map.GetAllAdjacentCells(adjacentCell, true).Any(c => c.Terrain != TerrainType.Rock)); }
private Point ConstructLocationAccordingToDoorOrientation(Cell cell, Map<Cell> map ) { Cell adjacentCell; if (map.TryGetAdjacentCell(cell, Direction.East, out adjacentCell) && adjacentCell.Terrain == TerrainType.Floor) return new Point(TILE_SIZE * 6,0); return new Point(TILE_SIZE * 4,0); }
private Point ConstructWallLocationAccordingToAdjacentWalls(Cell cell, Map<Cell> map) { if (map.GetAllAdjacentCells(cell, true).All(c => c.Terrain == TerrainType.Rock)) return new Point(TILE_SIZE*6, TILE_SIZE*5); short wallsFlag = 0; if (ShouldConsiderRockCell(cell, Direction.North, map)) wallsFlag |= NORTH; if (ShouldConsiderRockCell(cell, Direction.South, map)) wallsFlag |= SOUTH; if (ShouldConsiderRockCell(cell, Direction.West, map)) wallsFlag |= WEST; if (ShouldConsiderRockCell(cell, Direction.East, map)) wallsFlag |= EAST; if (mWallLocationByAdjacentRockCells.ContainsKey(wallsFlag)) return mWallLocationByAdjacentRockCells[wallsFlag]; return new Point(TILE_SIZE*6, TILE_SIZE*5); }
private Point ConstructFloorLocationAccordingToWalls(Cell cell, Map<Cell> map) { short wallsFlag = 0; Cell adjacentCell = null; if (map.TryGetAdjacentCell(cell, Direction.North, out adjacentCell) && adjacentCell.Terrain == TerrainType.Rock) wallsFlag |= NORTH; if (map.TryGetAdjacentCell(cell, Direction.West, out adjacentCell) && adjacentCell.Terrain == TerrainType.Rock) wallsFlag |= WEST; if (map.TryGetAdjacentCell(cell, Direction.South, out adjacentCell) && adjacentCell.Terrain == TerrainType.Rock) wallsFlag |= SOUTH; if (map.TryGetAdjacentCell(cell, Direction.East, out adjacentCell) && adjacentCell.Terrain == TerrainType.Rock) wallsFlag |= EAST; return mFloorLocationByAdjacentRockCells[wallsFlag]; }