private void createButton_Click(object sender, EventArgs e) { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Room = CreateRoom(); this.Close(); }
public TileChange(int x, int y, int to, int from, Type nature, Room room) { X = x; Y = y; ToIndex = to; FromIndex = from; Nature = nature; Room = room; }
private Room CreateRoom() { var x = numericTextBoxX.IntValue; var y = numericTextBoxY.IntValue; var width = numericTextBoxWidth.IntValue; var height = numericTextBoxHeight.IntValue; Room newRoom = new Room(-1, x, y, width, height); CameraBounds cameraBounds = new CameraBounds(); cameraBounds.X = 0; cameraBounds.Y = 0; cameraBounds.Width = width; cameraBounds.Height = height; newRoom.CameraBounds = cameraBounds; return newRoom; }
void CreateRoomDialog_Shown(object sender, EventArgs e) { this.Room = null; this.DialogResult = System.Windows.Forms.DialogResult.None; }
private void PerformFloodFill(Room room, int x, int y, int fromValue, int toValue) { if (x < 0 || x >= room.Width || y < 0 || y >= room.Height) { return; } var linearTileOffset = (y * room.Width) + x; var tiles = room.TileIndicies; var oldTileValue = tiles[linearTileOffset]; if (oldTileValue == fromValue && oldTileValue != toValue) { tiles[linearTileOffset] = toValue; AddTileUndo(x, y, oldTileValue, toValue, TileChange.Type.Tile, room); // Top PerformFloodFill(room, x, y - 1, fromValue, toValue); // Right PerformFloodFill(room, x + 1, y, fromValue, toValue); // Bottom PerformFloodFill(room, x, y + 1, fromValue, toValue); // Left PerformFloodFill(room, x - 1, y, fromValue, toValue); } }
private MapPanel GenerateMapPanelForRoom(Map map, Room room) { MapPanel panel = new MapPanel(); panel.Anchor = AnchorStyles.Left | AnchorStyles.Top; panel.BackColor = System.Drawing.SystemColors.ControlDark; panel.Font = new System.Drawing.Font("Consolas", 8F); panel.Location = new System.Drawing.Point(room.X * map.GridSize, room.Y * map.GridSize); panel.Margin = new System.Windows.Forms.Padding(0); panel.Size = new System.Drawing.Size(room.Width * map.GridSize, room.Height * map.GridSize); panel.MouseDown += new MouseEventHandler(panel_MouseDown); panel.MouseUp += new MouseEventHandler(panel_MouseUp); panel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.mapPanel_MouseMove); panel.MouseClick += new MouseEventHandler(HandleMapPanelClick); panel.MouseEnter += new EventHandler(mapPanel_MouseEnter); panel.MouseLeave += new EventHandler(mapPanel_MouseLeave); panel.KeyDown += new KeyEventHandler(HandleKeyDownForMapPanel); panel.Map = map; panel.Tiles = null; panel.Room = room; return panel; }
private void AddTileUndo(int x, int y, int from, int to, TileChange.Type nature, Room room) { currentUndo.Changes.Push(new TileChange(x, y, to, from, nature, room)); }