Esempio n. 1
0
        private void showPlayerAvailableMoves()
        {
            m_GameToPlay.buildNextMovesList();
            if (m_GameToPlay.NextMovesList.Count == 0)
            {
                bool isGameOver = m_GameToPlay.AreNoTilesAvailable();
                if (!isGameOver)
                {
                    MessageBox.Show("Current player doesn't have any valid moves. Turn is being skipped...");
                    switchPlayer();
                    showPlayerAvailableMoves();
                }
                else
                {
                    showGameOverDialog();
                }
            }

            foreach (NextMoves nextMove in m_GameToPlay.NextMovesList)
            {
                Ex02_Othelo_Logic.Point validTile = nextMove.NewCoinInBoard;
                m_TilesMatrix[validTile.XCoord, validTile.YCoord].BackColor = Color.LimeGreen;
                m_TilesMatrix[validTile.XCoord, validTile.YCoord].Enabled   = true;
            }
        }
Esempio n. 2
0
 private void playNextTurn()
 {
     updateTilesMatrix();
     showPlayerAvailableMoves();
     if (!m_GameToPlay.CurrentPlayer.HumanPlayer)
     {
         Ex02_Othelo_Logic.Point computerTile = m_GameToPlay.GenerateComputerTile();
         pictureBox_Click(m_TilesMatrix[computerTile.XCoord, computerTile.YCoord], null);
     }
 }
Esempio n. 3
0
        private void pictureBox_Click(object sender, EventArgs e)
        {
            Ex02_Othelo_Logic.Point chosenTile = getPictureBoxCoordinates((PictureBox)sender);
            m_GameToPlay.PickTile(chosenTile);
            (sender as PictureBox).BackColor = Color.Blue;
            if (!m_GameToPlay.CurrentPlayer.HumanPlayer)
            {
                MessageBox.Show("Computer chose the tile marked in blue");
                System.Threading.Thread.Sleep(500);
            }

            switchPlayer();
            playNextTurn();
        }
Esempio n. 4
0
        private Ex02_Othelo_Logic.Point getPictureBoxCoordinates(PictureBox i_PictureBoxTile)
        {
            int gameDimension = m_TilesMatrix.GetLength(0);

            Ex02_Othelo_Logic.Point pictureBoxPoint = new Ex02_Othelo_Logic.Point();
            for (int i = 0; i < gameDimension; i++)
            {
                for (int j = 0; j < gameDimension; j++)
                {
                    if (m_TilesMatrix[i, j].Equals(i_PictureBoxTile))
                    {
                        pictureBoxPoint.XCoord = i;
                        pictureBoxPoint.YCoord = j;
                    }
                }
            }

            return(pictureBoxPoint);
        }