Exemplo n.º 1
0
        private void contextMenuCellClearAgents_Click(object sender, EventArgs e)
        {
            var convertedSender = sender as ToolStripMenuItem;
            var cellToClear     = convertedSender.Owner.Tag as HexagonCell;

            if (cellToClear != null)
            {
                cellToClear.InnerAgent = null;
            }
            MainEditorPanel.Refresh();
        }
Exemplo n.º 2
0
        private void MainMenuFileNew_Click(object sender, EventArgs e)
        {
            var newGridWindow = new NewFileWindow();

            newGridWindow.ShowDialog(this);
            if (newGridWindow.GridSize > 0)
            {
                EditingGrid = new HexagonalGrid(newGridWindow.GridSize);
                MainEditorPanel.Refresh();
            }
        }
Exemplo n.º 3
0
        private void MainEditorPanel_DragDrop(object sender, DragEventArgs e)
        {
            var agentDropped = e.Data.GetData(e.Data.GetFormats()[0]) as Agent;                                                //Getting dropped data

            var newCoords  = MainEditorPanel.PointToClient(new Point(e.X, e.Y));                                               //Getting client coords from screen
            var cellToEdit = EditingGrid.GetCellByXYCoord(newCoords.X - totalShiftVector.X, newCoords.Y - totalShiftVector.Y); //Getting cell from coords to add agent in it

            if (cellToEdit != null)
            {
                cellToEdit.InnerAgent = agentDropped;
                EditingGrid.AddOrReplaceCell(cellToEdit);
            }

            MainEditorPanel.Refresh();
        }
Exemplo n.º 4
0
        private void contextMenuCellSelect_Click(object sender, EventArgs e)
        {
            var convertedSender = sender as ToolStripMenuItem;
            var cellToSelect    = convertedSender.Owner.Tag as HexagonCell;

            if (cellToSelect != null)
            {
                if (selectedCells.Contains(cellToSelect))
                {
                    selectedCells.Remove(cellToSelect);
                }
                else
                {
                    selectedCells.Add(cellToSelect);
                }
            }
            MainEditorPanel.Refresh();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Used for dragging and for updating mouse coords in the tool bar
        /// </summary>
        private void MainEditorPanel_MouseMove(object sender, MouseEventArgs e)
        {
            var currentCell = EditingGrid.GetCellByXYCoord(e.X - totalShiftVector.X, e.Y - totalShiftVector.Y);                      //Current cell that is covered with mouse

            if (currentTileBrush != null && currentCell != null)
            {
                brushCovering = EditingGrid.GetCellNeighboursOfRadius(currentCell, currentTileBrush.Size);

                #region Left mouse button for tile drawing

                if (leftMouseButtonInMapIsPressed)
                {
                    foreach (var cell in brushCovering)
                    {
                        cell.PresentedTile = currentTileBrush.CurrentTile;
                        EditingGrid.AddOrReplaceCell(cell);
                    }
                }

                #endregion

                MainEditorPanel.Refresh();
            }

            if (MouseCoordsChanged != null)
            {
                var newMouseEventArgs = new MouseEventArgs(e.Button, e.Clicks, e.X - totalShiftVector.X, e.Y - totalShiftVector.Y, e.Delta);
                MouseCoordsChanged(this, newMouseEventArgs);
            }

            #region Middle mouse button for dragging

            if (middleMouseButtonInMapIsPressed)
            {
                dragVector.X = e.X - mouseDownPoint.X;
                dragVector.Y = e.Y - mouseDownPoint.Y;
                MainEditorPanel.Refresh();
            }

            #endregion
        }
Exemplo n.º 6
0
 private void MainMenuEditorDeselectCells_Click(object sender, EventArgs e)
 {
     selectedCells.Clear();
     MainEditorPanel.Refresh();
 }