Beispiel #1
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (currentMap != null && currentCell != null)
     {
         CellMouseDown?.Invoke(currentMap, currentCell, e);
     }
 }
Beispiel #2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (currentMap == null)
            {
                return;
            }

            Rectangle rectangle = Renderer.GetBounds(currentMap, Width, Height);
            int       xpos      = rectangle.X + (AllowEdgePlacement ? 0 : rectangle.Width);
            int       ypos      = rectangle.Y + (AllowEdgePlacement ? 0 : rectangle.Height);
            int       edge      = AllowEdgePlacement ? 0 : 2;

            if (CheckBounds(e.X, e.Y, xpos, ypos, rectangle.Width * (currentMap.Width - edge), rectangle.Height * (currentMap.Height - edge)))
            {
                int xOrig  = rectangle.X;
                int size   = currentMap.Cells.Count;
                int rowEnd = rectangle.X + rectangle.Width * currentMap.Width;
                for (int i = 0; i < size; i++)
                {
                    Cell cell = currentMap.Cells[i];

                    if (CheckBounds(e.X, e.Y, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height))
                    {
                        if (currentCell != cell)
                        {
                            currentCell = cell;
                            CellMouseOver?.Invoke(currentMap, cell, e);
                            if (e.Button != MouseButtons.None)
                            {
                                CellMouseDown?.Invoke(currentMap, currentCell, e);
                            }
                        }
                        return;
                    }

                    rectangle.X += rectangle.Width;
                    if (rectangle.X >= rowEnd)
                    {
                        rectangle.Y += rectangle.Height;
                        rectangle.X  = xOrig;
                    }
                }
            }
            else if (currentCell != null)
            {
                currentCell = null;
                CellMouseOver?.Invoke(currentMap, null, e);
            }
        }
Beispiel #3
0
 private void OnCellMouseDown(BoardCell cell)
 {
     AudioManager.Instance.PlayOneShot(this.cellClickSound);
     CellMouseDown?.Invoke(cell);
 }
Beispiel #4
0
 private void OnCellMouseDown(CellMouseDownEventArgs e)
 {
     CellMouseDown?.Invoke(this, e);
 }