예제 #1
0
        private void Gomoku_MouseDown(object sender, MouseEventArgs e)
        {
            piece piece = game.PlaceAPiece(e.X, e.Y);

            if (piece != null)
            {
                this.Controls.Add(piece);
            }
            //Check Win?
            if (game.Winner == PieceType.BLACK)
            {
                MessageBox.Show("BLACK win.");
            }
            else if (game.Winner == PieceType.WHITE)
            {
                MessageBox.Show("White win.");
            }
        }
예제 #2
0
        public piece PlaceAPiece(int x, int y)
        {
            piece piece = board.PlaceAPiece(x, y, currentPlayer);

            if (piece != null)
            {
                //check Win?
                CheckWinner();
                if (currentPlayer == PieceType.BLACK)
                {
                    currentPlayer = PieceType.WHITE;
                }
                else if (currentPlayer == PieceType.WHITE)
                {
                    currentPlayer = PieceType.BLACK;
                }
                return(piece);
            }
            return(null);
        }