/// <summary> /// Draw each of the room doors. This goes over top of the base layer and /// is offset from the base. It will draw doors normal (white), locked (yellow), /// or wizard or spell locked (red) /// </summary> /// <param name="surface"></param> /// <param name="wallRecord"></param> /// <param name="yellowBrush"></param> /// <param name="x"></param> /// <param name="redBrush"></param> /// <param name="whiteBrush"></param> /// <param name="y"></param> private static void DrawRoomDoors(Graphics surface, GeoWallRecord wallRecord, SolidBrush yellowBrush, int x, SolidBrush redBrush, SolidBrush whiteBrush, int y) { var doorX = 0; var doorY = 0; var doorW = 0; var doorH = 0; var northDoor = wallRecord.Door & 3; var eastDoor = ((wallRecord.Door >> 2) & 3); var southDoor = ((wallRecord.Door >> 4) & 3); var westDoor = ((wallRecord.Door >> 6) & 3); var doorBrushes = new[] { null, whiteBrush, yellowBrush, redBrush }; if (northDoor > 0) { doorX = x + (WallThickness * 2); doorY = y; doorW = RoomSize - (WallThickness * 4); doorH = WallThickness * 2; surface.FillRectangle(doorBrushes[northDoor], doorX, doorY, doorW, doorH); } if (eastDoor > 0) { doorX = x + RoomSize - (WallThickness * 2); doorY = y + (WallThickness * 2); doorW = WallThickness * 2; doorH = RoomSize - (WallThickness * 4); surface.FillRectangle(doorBrushes[eastDoor], doorX, doorY, doorW, doorH); } if (southDoor > 0) { doorX = x + (WallThickness * 2); doorY = y + RoomSize - (WallThickness * 2); doorW = RoomSize - (WallThickness * 4); doorH = WallThickness * 2; surface.FillRectangle(doorBrushes[southDoor], doorX, doorY, doorW, doorH); } if (westDoor <= 0) { return; } // West doorX = x; doorY = y + (WallThickness * 2); doorW = WallThickness * 2; doorH = RoomSize - (WallThickness * 4); surface.FillRectangle(doorBrushes[westDoor], doorX, doorY, doorW, doorH); }
private int getOppositeWall(GeoWallRecord w, int facing) { switch (facing) { case 0: return(w.North); case 1: return(w.East); case 2: return(w.South); case 3: return(w.West); default: return(0); } }
/// <summary> /// Draw an indicator that this room has an event associated with it /// </summary> /// <param name="surface"></param> /// <param name="wallRecord"></param> /// <param name="y"></param> /// <param name="eventBrush"></param> /// <param name="x"></param> private static void DrawRoomEvent(Graphics surface, GeoWallRecord wallRecord, int y, Brush eventBrush, int x) { var font = new Font("Courier New", 12); var brush = new SolidBrush(Color.FromArgb(0, 0, 0)); var point = new PointF(x, y); var rectSize = new SizeF(RoomSize, RoomSize); if (wallRecord.Event > 0) { surface.FillRectangle(eventBrush, x, y, RoomSize, RoomSize); if ((wallRecord.Event & 127) > 0) { surface.DrawString((wallRecord.Event & 127).ToString(), font, brush, point); } } }
/// <summary> /// Draws a single room on the town map /// </summary> /// <param name="surface"></param> /// <param name="wallRecord"></param> private static void DrawRoom(Graphics surface, GeoWallRecord wallRecord) { var whiteBrush = new SolidBrush(Color.White); var yellowBrush = new SolidBrush(Color.Yellow); var redBrush = new SolidBrush(Color.Red); var grayBrush = new SolidBrush(Color.FromArgb(85, 85, 85)); var wallColor = Color.FromArgb(170, 170, 170); var wallBrush = new SolidBrush(wallColor); var eventBrush = new SolidBrush(Color.ForestGreen); var x = wallRecord.Column * RoomSize + GutterSize; var y = wallRecord.Row * RoomSize + GutterSize; DrawRoomBase(surface, y, grayBrush, x); DrawRoomEvent(surface, wallRecord, y, eventBrush, x); DrawRoomWalls(surface, wallRecord, WallThickness, y, wallBrush, x); DrawRoomDoors(surface, wallRecord, yellowBrush, x, redBrush, whiteBrush, y); }
/// <summary> /// Draw the four walls surrounding the room /// </summary> /// <param name="surface"></param> /// <param name="wallRecord"></param> /// <param name="wallThickness"></param> /// <param name="y"></param> /// <param name="wallBrush"></param> /// <param name="x"></param> private static void DrawRoomWalls(Graphics surface, GeoWallRecord wallRecord, int wallThickness, int y, Brush wallBrush, int x) { if (wallRecord.North != 0) { surface.FillRectangle(wallBrush, x, y, RoomSize, wallThickness); } if (wallRecord.East != 0) { surface.FillRectangle(wallBrush, x + RoomSize - wallThickness, y, wallThickness, RoomSize); } if (wallRecord.South != 0) { surface.FillRectangle(wallBrush, x, y + RoomSize - wallThickness, RoomSize, wallThickness); } if (wallRecord.West != 0) { surface.FillRectangle(wallBrush, x, y, wallThickness, RoomSize); } }
private int getLeftWall(GeoWallRecord w, string facing) { int wallType = 0; if (facing == "w") { wallType = w.South; } if (facing == "e") { wallType = w.North; } if (facing == "s") { wallType = w.East; } if (facing == "n") { wallType = w.West; } return(wallType); }
private int getLeftWall(GeoWallRecord w, int facing) { return(getOppositeWall(w, (facing + 3) % 4)); }
/// <summary> /// Draw an indicator that this room has an event associated with it /// </summary> /// <param name="surface"></param> /// <param name="wallRecord"></param> /// <param name="y"></param> /// <param name="eventBrush"></param> /// <param name="x"></param> private static void DrawRoomEvent(Graphics surface, GeoWallRecord wallRecord, int y, Brush eventBrush, int x) { var font = new Font("Courier New", 12); var brush = new SolidBrush(Color.FromArgb(0, 0, 0)); var point = new PointF(x, y); var rectSize = new SizeF(RoomSize, RoomSize); if (wallRecord.Event > 0) { surface.FillRectangle(eventBrush, x, y, RoomSize, RoomSize); if ((wallRecord.Event & 127) > 0) surface.DrawString((wallRecord.Event & 127).ToString(), font, brush, point); } }
/// <summary> /// Draw the four walls surrounding the room /// </summary> /// <param name="surface"></param> /// <param name="wallRecord"></param> /// <param name="wallThickness"></param> /// <param name="y"></param> /// <param name="wallBrush"></param> /// <param name="x"></param> private static void DrawRoomWalls(Graphics surface, GeoWallRecord wallRecord, int wallThickness, int y, Brush wallBrush, int x) { if (wallRecord.North != 0) { surface.FillRectangle(wallBrush, x, y, RoomSize, wallThickness); } if (wallRecord.East != 0) { surface.FillRectangle(wallBrush, x + RoomSize - wallThickness, y, wallThickness, RoomSize); } if (wallRecord.South != 0) { surface.FillRectangle(wallBrush, x, y + RoomSize - wallThickness, RoomSize, wallThickness); } if (wallRecord.West != 0) { surface.FillRectangle(wallBrush, x, y, wallThickness, RoomSize); } }
/// <summary> /// Draw each of the room doors. This goes over top of the base layer and /// is offset from the base. It will draw doors normal (white), locked (yellow), /// or wizard or spell locked (red) /// </summary> /// <param name="surface"></param> /// <param name="wallRecord"></param> /// <param name="yellowBrush"></param> /// <param name="x"></param> /// <param name="redBrush"></param> /// <param name="whiteBrush"></param> /// <param name="y"></param> private static void DrawRoomDoors(Graphics surface, GeoWallRecord wallRecord, SolidBrush yellowBrush, int x, SolidBrush redBrush, SolidBrush whiteBrush, int y) { var doorX = 0; var doorY = 0; var doorW = 0; var doorH = 0; var northDoor = wallRecord.Door & 3; var eastDoor = ((wallRecord.Door >> 2) & 3); var southDoor = ((wallRecord.Door >> 4) & 3); var westDoor = ((wallRecord.Door >> 6) & 3); var doorBrushes = new[] { null, whiteBrush, yellowBrush, redBrush }; if (northDoor > 0) { doorX = x + (WallThickness * 2); doorY = y; doorW = RoomSize - (WallThickness * 4); doorH = WallThickness * 2; surface.FillRectangle(doorBrushes[northDoor], doorX, doorY, doorW, doorH); } if (eastDoor > 0) { doorX = x + RoomSize - (WallThickness * 2); doorY = y + (WallThickness * 2); doorW = WallThickness * 2; doorH = RoomSize - (WallThickness * 4); surface.FillRectangle(doorBrushes[eastDoor], doorX, doorY, doorW, doorH); } if (southDoor > 0) { doorX = x + (WallThickness * 2); doorY = y + RoomSize - (WallThickness * 2); doorW = RoomSize - (WallThickness * 4); doorH = WallThickness * 2; surface.FillRectangle(doorBrushes[southDoor], doorX, doorY, doorW, doorH); } if (westDoor <= 0) return; // West doorX = x; doorY = y + (WallThickness * 2); doorW = WallThickness * 2; doorH = RoomSize - (WallThickness * 4); surface.FillRectangle(doorBrushes[westDoor], doorX, doorY, doorW, doorH); }
/// <summary> /// Draws a single room on the town map /// </summary> /// <param name="surface"></param> /// <param name="wallRecord"></param> private static void DrawRoom(Graphics surface, GeoWallRecord wallRecord) { var whiteBrush = new SolidBrush(Color.White); var yellowBrush = new SolidBrush(Color.Yellow); var redBrush = new SolidBrush(Color.Red); var grayBrush = new SolidBrush(Color.FromArgb(85, 85, 85)); var wallColor = Color.FromArgb(170, 170, 170); var wallBrush = new SolidBrush(wallColor); var eventBrush = new SolidBrush(Color.ForestGreen); var x = wallRecord.Column * RoomSize + GutterSize; var y = wallRecord.Row * RoomSize + GutterSize; DrawRoomBase(surface, y, grayBrush, x); DrawRoomEvent(surface, wallRecord, y, eventBrush, x); DrawRoomWalls(surface, wallRecord, WallThickness, y, wallBrush, x); DrawRoomDoors(surface, wallRecord, yellowBrush, x, redBrush, whiteBrush, y); }
private int getLeftWall(GeoWallRecord w, string facing) { int wallType = 0; if (facing == "w") wallType = w.South; if (facing == "e") wallType = w.North; if (facing == "s") wallType = w.East; if (facing == "n") wallType = w.West; return wallType; }