private void CreateRoom(int x, int y, _Room room) { const int RM_SIZE = 200; const int DR_LONG = 50; const int DR_SKINNY = 20; Rectangle rect; // Create main rect rect = ColoredRectInit(Colors.Black, Colors.Beige); rect.Width = RM_SIZE; rect.Height = RM_SIZE; Canvas.SetLeft(rect, x); Canvas.SetTop(rect, y); mainCanvas.Children.Add(rect); if (room.NorthDoor) { // Create door (N) rect = ColoredRectInit(Colors.DarkOrange, Colors.Orange); rect.Width = DR_LONG; rect.Height = DR_SKINNY; Canvas.SetLeft(rect, x + RM_SIZE / 2 - rect.Width / 2); Canvas.SetTop(rect, y - rect.Height); mainCanvas.Children.Add(rect); } if (room.SouthDoor) { // Create door (S) rect = ColoredRectInit(Colors.DarkOrange, Colors.Orange); rect.Width = DR_LONG; rect.Height = DR_SKINNY; Canvas.SetLeft(rect, x + RM_SIZE / 2 - rect.Width / 2); Canvas.SetTop(rect, y + RM_SIZE); mainCanvas.Children.Add(rect); } if (room.EastDoor) { // Create door (E) rect = ColoredRectInit(Colors.DarkOrange, Colors.Orange); rect.Width = DR_SKINNY; rect.Height = DR_LONG; Canvas.SetLeft(rect, x + RM_SIZE); Canvas.SetTop(rect, y + RM_SIZE / 2 - rect.Height / 2); mainCanvas.Children.Add(rect); } if (room.WestDoor) { // Create door (W) rect = ColoredRectInit(Colors.DarkOrange, Colors.Orange); rect.Width = DR_SKINNY; rect.Height = DR_LONG; Canvas.SetLeft(rect, x - rect.Width); Canvas.SetTop(rect, y + RM_SIZE / 2 - rect.Height / 2); mainCanvas.Children.Add(rect); } }
public MainWindow() { InitializeComponent(); var sampleRoom = new _Room(true, false, true, true); CreateRoom(20, 20, sampleRoom); }