示例#1
0
        private void Reset_Click(object sender, EventArgs e)
        {
            GameBoard.ResetBoard();

            panel1.Refresh();
            CurrentColorDisplayPanel.Refresh();

            LabelAmount.Text = "黒:0 白:0";
            TurnLabel.Text   = "0";
            TipLabel.Text    = "";
        }
示例#2
0
        private void MouseClicked(object sender, MouseEventArgs e)
        {
            System.Drawing.Point sp = System.Windows.Forms.Cursor.Position;
            System.Drawing.Point cp = panel1.PointToClient(sp);

            int posX, posY;

            GameBoard.GetGridPosition(cp.X, cp.Y, GameDisplay, out posX, out posY);

            if (GameBoard.CanPlace(GameBoard.CurrentColor, posX, posY) == true)
            {
                GameBoard.Place(GameBoard.CurrentColor, posX, posY);
                GameBoard.Turn++;
                GameBoard.ChangeTurn();

                panel1.Refresh();
                CurrentColorDisplayPanel.Refresh();

                LabelAmount.Text = string.Format("黒:{0} 白:{1}", GameBoard.GetAmount(Black), GameBoard.GetAmount(White));
                TurnLabel.Text   = string.Format("{0}", GameBoard.Turn);
                TipLabel.Text    = "";

                if (GameBoard.CheckGameEnd() == true)
                {
                    if (GameBoard.GetAmount(Black) > GameBoard.GetAmount(White))
                    {
                        TipLabel.Text = "黒の勝利でゲームは終了しました";
                    }
                    else if (GameBoard.GetAmount(Black) < GameBoard.GetAmount(White))
                    {
                        TipLabel.Text = "白の勝利でゲームは終了しました";
                    }
                    else if (GameBoard.GetAmount(Black) == GameBoard.GetAmount(White))
                    {
                        TipLabel.Text = "引き分けでゲームは終了しました";
                    }
                }
                else
                {
                    if (GameBoard.CanPlaceMyColor(GameBoard.CurrentColor) == false)
                    {
                        GameBoard.Turn++;
                        GameBoard.ChangeTurn();
                        TipLabel.Text = string.Format("{0}番目の手はスキップされました", GameBoard.Turn - 1);
                    }
                    else
                    {
                        TipLabel.Text = "";
                    }
                }
            }
        }