示例#1
0
        private void createButton_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;

            this.Room = CreateRoom();

            this.Close();
        }
示例#2
0
 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;
 }
示例#3
0
        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;
        }
示例#4
0
 void CreateRoomDialog_Shown(object sender, EventArgs e)
 {
     this.Room = null;
     this.DialogResult = System.Windows.Forms.DialogResult.None;
 }
示例#5
0
        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);
            }
        }
示例#6
0
        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;
        }
示例#7
0
 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));
 }