Exemple #1
0
        private void computerTurn()
        {
            System.Threading.Thread.Sleep(1000);
            GameLogic.Point firstChoise = m_GameManager.ComputerRandomChoise();
            m_GameManager.PlayChoise(firstChoise);
            exposeSlot(firstChoise);

            System.Threading.Thread.Sleep(1000);
            GameLogic.Point secondChoise = m_GameManager.ComputerRandomChoise(firstChoise);
            exposeSlot(secondChoise);

            if (m_GameManager.PlayChoise(m_IsFirstPlayerTurn, firstChoise, secondChoise))
            {
                updatePlayersInfoLabels();

                if (m_GameManager.IsGameOver())
                {
                    gameOverDialog();
                }
                else
                {
                    computerTurn();
                }
            }
            else
            {
                System.Threading.Thread.Sleep(1000);
                m_IsFirstPlayerTurn = !m_IsFirstPlayerTurn;
                updateCurrentPlayerLabel();
                m_GameManager.m_GameBoard.FlipSlot(firstChoise);
                m_GameManager.m_GameBoard.FlipSlot(secondChoise);
                hideSlot(firstChoise);
                hideSlot(secondChoise);
            }
        }
Exemple #2
0
        private void hideSlot(GameLogic.Point i_Point)
        {
            int rowIndex = i_Point.RowIndex;
            int colIndex = i_Point.ColumnIndex;

            m_GameForm.SlotButtons[rowIndex, colIndex].Enabled         = true;
            m_GameForm.SlotButtons[rowIndex, colIndex].BackgroundImage = null;
            m_GameForm.SlotButtons[rowIndex, colIndex].FlatStyle       = FlatStyle.System;
            m_GameForm.SlotButtons[rowIndex, colIndex].Update();
        }
Exemple #3
0
        private void exposeSlot(GameLogic.Point i_Point)
        {
            Color backColorCurrentPlayer = m_IsFirstPlayerTurn ? m_GameForm.FirstPlayerScore.BackColor : m_GameForm.SecondPlayerScore.BackColor;
            int   rowIndex = i_Point.RowIndex;
            int   colIndex = i_Point.ColumnIndex;
            Image slotImage;

            m_ImagesCollection.TryGetValue(m_GameManager.m_GameBoard.SlotBoard[rowIndex, colIndex].Letter, out slotImage);

            m_GameForm.SlotButtons[rowIndex, colIndex].Enabled                    = false;
            m_GameForm.SlotButtons[rowIndex, colIndex].BackgroundImage            = slotImage;
            m_GameForm.SlotButtons[rowIndex, colIndex].FlatStyle                  = FlatStyle.Flat;
            m_GameForm.SlotButtons[rowIndex, colIndex].FlatAppearance.BorderColor = backColorCurrentPlayer;
            m_GameForm.SlotButtons[rowIndex, colIndex].FlatAppearance.BorderSize  = 3;
            m_GameForm.SlotButtons[rowIndex, colIndex].Update();
        }
Exemple #4
0
        private void playChoise(GameSlot i_SlotClicked)
        {
            GameLogic.Point pointChosen = i_SlotClicked.SlotPoint;
            exposeSlot(pointChosen);

            if (m_IsFirstChoise)
            {
                m_GameManager.PlayChoise(pointChosen);
                m_FirstChoise   = i_SlotClicked;
                m_IsFirstChoise = false;
            }
            else
            {
                System.Threading.Thread.Sleep(1000);

                if (m_GameManager.PlayChoise(m_IsFirstPlayerTurn, m_FirstChoise.SlotPoint, pointChosen))
                {
                    updatePlayersInfoLabels();

                    if (m_GameManager.IsGameOver())
                    {
                        gameOverDialog();
                    }
                }
                else
                {
                    m_GameManager.m_GameBoard.FlipSlot(pointChosen);
                    m_GameManager.m_GameBoard.FlipSlot(m_FirstChoise.SlotPoint);
                    hideSlot(pointChosen);
                    hideSlot(m_FirstChoise.SlotPoint);
                    m_IsFirstPlayerTurn = !m_IsFirstPlayerTurn;
                    updateCurrentPlayerLabel();

                    if (!m_GameManager.IsSecondPlayerReal())
                    {
                        computerTurn();
                    }
                }

                m_IsFirstChoise = true;
            }
        }