예제 #1
0
        private void deck1PictureBoxMouseMove(object sender, MouseEventArgs e)
        {
            // Are we on the grid of the first deck?
            if (GraphicContext.GetCoorX(this, deck1PictureBox) != -1 && GraphicContext.GetCoorY(this, deck1PictureBox) != -1)
            {
                // Have the cell selected by mouse changed?
                if (GraphicContext.GetCell(GraphicContext.GetCoorX(this, deck1PictureBox)) != mouseCellX || GraphicContext.GetCell(GraphicContext.GetCoorY(this, deck1PictureBox)) != mouseCellY)
                {
                    // Update the cell selected by mouse.
                    mouseCellX = GraphicContext.GetCell(GraphicContext.GetCoorX(this, deck1PictureBox));
                    mouseCellY = GraphicContext.GetCell(GraphicContext.GetCoorY(this, deck1PictureBox));

                    // Repaint the first deck.
                    deck1PictureBox.Refresh();

                    // Draw the outer frame of the selected cell.
                    GraphicContext.DrawOuterFrameCell(mouseCellX, mouseCellY, 5, this, deck1PictureBox);
                }
            }
            else
            {
                // Unselect the cell in the first deck.
                mouseCellX = -1;
                mouseCellY = -1;

                // Repaint the first deck.
                deck1PictureBox.Refresh();
            }
        }
예제 #2
0
        private void DeckPictureBoxMouseMove(object sender, MouseEventArgs e)
        {
            if (currentShip != -1)
            {
                if (GraphicContext.GetCoorX(this, deckPictureBox) != -1 && GraphicContext.GetCoorY(this, deckPictureBox) != -1)
                {
                    if (GraphicContext.GetCell(GraphicContext.GetCoorX(this, deckPictureBox)) != mouseCellX || GraphicContext.GetCell(GraphicContext.GetCoorY(this, deckPictureBox)) != mouseCellY)
                    {
                        mouseCellX = GraphicContext.GetCell(GraphicContext.GetCoorX(this, deckPictureBox));
                        mouseCellY = GraphicContext.GetCell(GraphicContext.GetCoorY(this, deckPictureBox));

                        deckPictureBox.Refresh();


                        if (shipRotation)
                        {
                            for (int i = 0; i < Game.shipLengths[currentShip]; i++)
                            {
                                if (mouseCellX + i <= 9)
                                {
                                    GraphicContext.DrawInnerFrameCell(mouseCellX + i, mouseCellY, currentShip, this, deckPictureBox);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < Game.shipLengths[currentShip]; i++)
                            {
                                if (mouseCellY + i <= 9)
                                {
                                    GraphicContext.DrawInnerFrameCell(mouseCellX, mouseCellY + i, currentShip, this, deckPictureBox);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (mouseCellX != -1 || mouseCellY != -1)
                    {
                        mouseCellX = -1;
                        mouseCellY = -1;


                        deckPictureBox.Refresh();
                    }
                }
            }
        }
예제 #3
0
        private void deck1PictureBoxPaint(object sender, PaintEventArgs e)
        {
            GraphicContext.DrawSunkenShips(opponentPlayer.ShipSet, opponentPlayer.ShipLeftCells, e);
            GraphicContext.DrawDeckStatus(opponentPlayer.RevealedCells, opponentPlayer.ShipSet, e);

            if (opponentPlayer.LastRevieledCells[0] != -1 && opponentPlayer.LastRevieledCells[1] != -1)
            {
                GraphicContext.DrawOuterFrameCell(opponentPlayer.LastRevieledCells[0], opponentPlayer.LastRevieledCells[1], 6, e);
            }
        }
예제 #4
0
        private void deck2PictureBoxPaint(object sender, PaintEventArgs e)
        {
            GraphicContext.DrawShipSet(yourPlayer.ShipSet, e);
            GraphicContext.DrawDeckStatus(yourPlayer.RevealedCells, yourPlayer.ShipSet, e);

            if (yourPlayer.LastRevieledCells[0] != -1 && yourPlayer.LastRevieledCells[1] != -1)
            {
                GraphicContext.DrawOuterFrameCell(yourPlayer.LastRevieledCells[0], yourPlayer.LastRevieledCells[1], 7, e);
            }
        }
예제 #5
0
 private void deck1PictureBoxMouseMove(object sender, MouseEventArgs e)
 {
     if (GraphicContext.GetCoorX(this, deck1PictureBox) != -1 && GraphicContext.GetCoorY(this, deck1PictureBox) != -1)
     {
         if (GraphicContext.GetCell(GraphicContext.GetCoorX(this, deck1PictureBox)) != mouseCellX || GraphicContext.GetCell(GraphicContext.GetCoorY(this, deck1PictureBox)) != mouseCellY)
         {
             mouseCellX = GraphicContext.GetCell(GraphicContext.GetCoorX(this, deck1PictureBox));
             mouseCellY = GraphicContext.GetCell(GraphicContext.GetCoorY(this, deck1PictureBox));
             deck1PictureBox.Refresh();
             GraphicContext.DrawOuterFrameCell(mouseCellX, mouseCellY, 5, this, deck1PictureBox);
         }
     }
     else
     {
         mouseCellX = -1;
         mouseCellY = -1;
         deck1PictureBox.Refresh();
     }
 }
예제 #6
0
 private void DeckPictureBoxPaint(object sender, PaintEventArgs e)
 {
     GraphicContext.DrawShipSet(player.ShipSet, e);
 }
        private void DeckPictureBoxMouseMove(object sender, MouseEventArgs e)
        {
            // Is there any ship selected?
            if (currentShip != -1)
            {
                // Are we on the grid of the deck?
                if (GraphicContext.GetCoorX(this, deckPictureBox) != -1 && GraphicContext.GetCoorY(this, deckPictureBox) != -1)
                {
                    // Has the mouse selected cell changed?
                    if (GraphicContext.GetCell(GraphicContext.GetCoorX(this, deckPictureBox)) != mouseCellX || GraphicContext.GetCell(GraphicContext.GetCoorY(this, deckPictureBox)) != mouseCellY)
                    {
                        // Rewrite Mouse cell information.
                        mouseCellX = GraphicContext.GetCell(GraphicContext.GetCoorX(this, deckPictureBox));
                        mouseCellY = GraphicContext.GetCell(GraphicContext.GetCoorY(this, deckPictureBox));

                        // Reraw the deck.
                        deckPictureBox.Refresh();

                        // Is the horizontal rotation on?
                        if (shipRotation)
                        {
                            // Deploy current ship with its color into the deck.
                            for (int i = 0; i < Game.shipLengths[currentShip]; i++)
                            {
                                // Do not corss the boundaries.
                                if (mouseCellX + i <= 9)
                                {
                                    GraphicContext.DrawInnerFrameCell(mouseCellX + i, mouseCellY, currentShip, this, deckPictureBox);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                        else
                        {
                            // Vertical rotation is on.
                            for (int i = 0; i < Game.shipLengths[currentShip]; i++)
                            {
                                if (mouseCellY + i <= 9)
                                {
                                    GraphicContext.DrawInnerFrameCell(mouseCellX, mouseCellY + i, currentShip, this, deckPictureBox);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    // Out of the boundaries of the deck.
                    if (mouseCellX != -1 || mouseCellY != -1)
                    {
                        mouseCellX = -1;
                        mouseCellY = -1;

                        // Reraw the deck.
                        deckPictureBox.Refresh();
                    }
                }
            }
        }