/// <summary> /// Generates cubes along our wall with a door in it. /// </summary> /// <param name="width">Width (floor coordinates) of the wall</param> /// <param name="height">Height (floor to ceiling) of the wall</param> /// <param name="maxDepth">Maximum depth the wall can poke out</param> /// <param name="minDepth">Minimum depth the wall can poke out</param> /// <param name="doorCode">Direction the door is facing</param> /// <param name="neighborCubes">Reference to the RoomCubes structure of the neighbor /// connected by this door.</param> public DoorWallCubes(int width, int height, int maxDepth, int minDepth, int doorCode, RoomCubes neighborCubes) { DoorCode = doorCode; int lWidth = (width - RogueDungeon.CORRIDOR_WIDTH) / 2; int rWidth = width - lWidth - RogueDungeon.CORRIDOR_WIDTH; R_Side = new StandardWallCubes(rWidth, height, maxDepth, minDepth); L_Side = new StandardWallCubes(lWidth, height, maxDepth, minDepth); // We need to know which type of Corridor Cubes to extract - use door code for that! if (doorCode == RogueRoom.LEFT_DOOR_MASK) { LRCorridorCubes corCubes = (LRCorridorCubes)neighborCubes; L_Corner = new OutsideCornerCubes(corCubes.DownWall.MaxDepth, L_Side.MaxDepth, L_Side.GetRightEdge(), corCubes.DownWall.GetRightEdge()); R_Corner = new OutsideCornerCubes(R_Side.MaxDepth, corCubes.UpWall.MaxDepth, corCubes.UpWall.GetRightEdge(), R_Side.GetLeftEdge()); } else if (doorCode == RogueRoom.RIGHT_DOOR_MASK) { LRCorridorCubes corCubes = (LRCorridorCubes)neighborCubes; L_Corner = new OutsideCornerCubes(corCubes.UpWall.MaxDepth, L_Side.MaxDepth, L_Side.GetRightEdge(), corCubes.UpWall.GetLeftEdge()); R_Corner = new OutsideCornerCubes(R_Side.MaxDepth, corCubes.DownWall.MaxDepth, corCubes.DownWall.GetLeftEdge(), R_Side.GetLeftEdge()); } else if (doorCode == RogueRoom.UP_DOOR_MASK) { UDCorridorCubes corCubes = (UDCorridorCubes)neighborCubes; L_Corner = new OutsideCornerCubes(corCubes.LeftWall.MaxDepth, L_Side.MaxDepth, L_Side.GetRightEdge(), corCubes.LeftWall.GetRightEdge()); R_Corner = new OutsideCornerCubes(R_Side.MaxDepth, corCubes.RightWall.MaxDepth, corCubes.RightWall.GetRightEdge(), R_Side.GetLeftEdge()); } else if (doorCode == RogueRoom.DOWN_DOOR_MASK) { UDCorridorCubes corCubes = (UDCorridorCubes)neighborCubes; L_Corner = new OutsideCornerCubes(corCubes.RightWall.MaxDepth, L_Side.MaxDepth, L_Side.GetRightEdge(), corCubes.RightWall.GetLeftEdge()); R_Corner = new OutsideCornerCubes(R_Side.MaxDepth, corCubes.LeftWall.MaxDepth, corCubes.LeftWall.GetLeftEdge(), R_Side.GetLeftEdge()); } else // ERROR! { throw new ArgumentException("Door code doesn't work D:"); } }
/// <summary> /// Constructs a new instance of the RoomCubes data structure, given the dimensions of /// the room the cubes are in. /// </summary> /// <param name="roomWidth">Width of the room</param> /// <param name="roomHeight">Height of the room</param> /// <param name="ceilingHeight">Height of the ceiling</param> public StandardRoomCubes(int roomWidth, int roomHeight, int doorCode, int ceilingHeight, RoomCubes lftNbr, RoomCubes rgtNbr, RoomCubes upNbr, RoomCubes dwnNbr) { Width = roomWidth; Depth = roomHeight; Height = ceilingHeight; int CORNER_DIM = 8; int wallDepth = (Depth - (CORNER_DIM * 2)) < 0 ? 0 : (Depth - (CORNER_DIM * 2)); int wallWidth = (Width - (CORNER_DIM * 2)) < 0 ? 0 : (Width - (CORNER_DIM * 2)); L_Wall = (doorCode & RogueRoom.LEFT_DOOR_MASK) == 0 ? (WallCubes)new StandardWallCubes(wallDepth, Height, CORNER_DIM, 3) : (WallCubes)new DoorWallCubes(wallDepth, Height, CORNER_DIM, 3, RogueRoom.LEFT_DOOR_MASK, lftNbr); R_Wall = (doorCode & RogueRoom.RIGHT_DOOR_MASK) == 0 ? (WallCubes)new StandardWallCubes(wallDepth, Height, CORNER_DIM, 3) : (WallCubes)new DoorWallCubes(wallDepth, Height, CORNER_DIM, 3, RogueRoom.RIGHT_DOOR_MASK, rgtNbr); T_Wall = (doorCode & RogueRoom.UP_DOOR_MASK) == 0 ? (WallCubes)new StandardWallCubes(wallWidth, Height, CORNER_DIM, 3) : (WallCubes)new DoorWallCubes(wallWidth, Height, CORNER_DIM, 3, RogueRoom.UP_DOOR_MASK, upNbr); B_Wall = (doorCode & RogueRoom.DOWN_DOOR_MASK) == 0 ? (WallCubes)new StandardWallCubes(wallWidth, Height, CORNER_DIM, 3) : (WallCubes)new DoorWallCubes(wallWidth, Height, CORNER_DIM, 3, RogueRoom.DOWN_DOOR_MASK, dwnNbr); TL_Corner = new InsideCornerCubes(L_Wall.MaxDepth, T_Wall.MaxDepth, T_Wall.GetLeftEdge(), L_Wall.GetRightEdge()); BL_Corner = new InsideCornerCubes(B_Wall.MaxDepth, L_Wall.MaxDepth, L_Wall.GetLeftEdge(), B_Wall.GetRightEdge()); TR_Corner = new InsideCornerCubes(T_Wall.MaxDepth, R_Wall.MaxDepth, R_Wall.GetLeftEdge(), T_Wall.GetRightEdge()); BR_Corner = new InsideCornerCubes(R_Wall.MaxDepth, B_Wall.MaxDepth, B_Wall.GetLeftEdge(), R_Wall.GetRightEdge()); }