コード例 #1
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            qizi qz = game.placeqizi(e.X, e.Y);

            if (qz != null)
            {
                this.Controls.Add(qz);
                //检查是否有人获胜
                if (game.winner == qztype.BLACK)
                {
                    MessageBox.Show("黑色获胜");
                    this.Close();
                }
                else if (game.winner == qztype.WHITE)
                {
                    MessageBox.Show("白色获胜");
                    this.Close();
                }
            }
        }
コード例 #2
0
ファイル: game.cs プロジェクト: lbbjzz/Gobang
        public qizi placeqizi(int x, int y)
        {
            qizi qz = qp.placeqizi(x, y, currentPlayer);

            if (qz != null)
            {
                //检查是否现在下棋的人获胜
                checkWinner();

                //交换棋手
                if (currentPlayer == qztype.BLACK)
                {
                    currentPlayer = qztype.WHITE;
                }
                else if (currentPlayer == qztype.WHITE)
                {
                    currentPlayer = qztype.BLACK;
                }
                return(qz);
            }
            return(null);
        }