예제 #1
0
        private PictureBoxCell initializePictureBox(int i_Row, int i_Col, int i_Top, int i_Left)
        {
            PictureBoxCell pictureBoxCell = new PictureBoxCell(i_Row, i_Col);

            pictureBoxCell.Left            = i_Left;
            pictureBoxCell.Top             = i_Top;
            pictureBoxCell.Width           = k_PictureBoxSize;
            pictureBoxCell.Height          = k_PictureBoxSize;
            pictureBoxCell.BorderStyle     = BorderStyle.Fixed3D;
            pictureBoxCell.SizeMode        = PictureBoxSizeMode.StretchImage;
            pictureBoxCell.BackgroundImage = Properties.Resources.Background;

            return(pictureBoxCell);
        }
예제 #2
0
        private void PictureBox_Click(object sender, EventArgs e)
        {
            PictureBoxCell   cell           = sender as PictureBoxCell;
            List <CellPoint> cellsToReplace = new List <CellPoint>();

            if (m_Game.TryMove(cell.Row, cell.Col, out cellsToReplace) && cellsToReplace.Count > 0)
            {
                m_Game.UpdateBoard(cellsToReplace);
                m_Game.ChangeTurn();
            }

            if (m_Game.IsThereArePossibleMoves())
            {
                if (m_Game.CurrentPlayerToPlay == Game.ePlayerId.Computer)
                {
                    m_Game.MakeComputerMoves();
                }
            }
            else
            {
                m_Game.ChangeTurn();
                if (!m_Game.IsThereArePossibleMoves())
                {
                    showScore();
                    EndGame();
                    return;
                }
            }

            showScore();
            this.updatePictureBoxBoard(m_Game.CurrentGame);
            showValidCells();
            updateTitle();
            this.Refresh();
            if (m_Game.CurrentGame.GameBoard.IsFull())
            {
                EndGame();
            }
        }