コード例 #1
0
        private void MemoryGameButton_Click(object i_Sender, EventArgs i_E)
        {
            MemoryGameButton button = i_Sender as MemoryGameButton;
            int        key          = MemoryBoard.GetKey(button.Row, button.Col);
            PictureBox picture      = GameManager.sr_ValueDictionary[key];

            if (!MemoryBoard.IsOpenOrTurnOpen(button.Row, button.Col))
            {
                if (IsFirstTile)
                {
                    playerChooseFirstTile(button);
                }
                else
                {
                    button.Image       = picture.Image;
                    button.BackColor   = Turn ? Player2Name.BackColor : Player1Name.BackColor;
                    SecondChoiceButton = button;

                    if (MemoryBoard.SecondChoice(button.Row, button.Col))
                    {
                        playerChooseSameTiles(button);
                    }
                    else
                    {
                        playerChooseDifferentTiles(button);
                    }

                    IsFirstTile = !IsFirstTile;
                }
            }
        }
コード例 #2
0
        private void makeComputerTurn()
        {
            const bool k_EnableButtons = false;

            enableDisableButtonsComputerTurn(k_EnableButtons);

            if (ComputerTurnState == eComputerTurnState.FirstTileToChoose)
            {
                firstTileChoosenByComputer();
            }
            else if (ComputerTurnState == eComputerTurnState.SecondTileToChoose)
            {
                secondTileChoosenByComputer();
            }
            else if (ComputerTurnState == eComputerTurnState.EndTurn)
            {
                int firstTileValue  = MemoryBoard.GetKey(FirstChoiceButton.Row, FirstChoiceButton.Col);
                int secondTileValue = MemoryBoard.GetKey(SecondChoiceButton.Row, SecondChoiceButton.Col);

                if (firstTileValue == secondTileValue)
                {
                    computerChooseSameTiles();
                }
                else
                {
                    computerChooseDifferentTiles();
                }

                ComputerTurnState = eComputerTurnState.FirstTileToChoose;
            }
        }
コード例 #3
0
        private void playerChooseFirstTile(MemoryGameButton i_BoardTileButton)
        {
            int        key     = MemoryBoard.GetKey(i_BoardTileButton.Row, i_BoardTileButton.Col);
            PictureBox picture = GameManager.sr_ValueDictionary[key];

            MemoryBoard.FirstChoice(i_BoardTileButton.Row, i_BoardTileButton.Col);
            i_BoardTileButton.Image     = picture.Image;
            IsFirstTile                 = !IsFirstTile;
            FirstChoiceButton           = i_BoardTileButton;
            i_BoardTileButton.BackColor = Turn ? Player2Name.BackColor : Player1Name.BackColor;
        }
コード例 #4
0
        private void secondTileChoosenByComputer()
        {
            Point secondOpened = new Point();
            int   key;

            ComputerPlayer.ZeroAndUpdateRevealedTiles(MemoryBoard);
            secondOpened = ComputerPlayer.ChooseSecondTile(MemoryBoard);
            key          = MemoryBoard.GetKey(secondOpened.X, secondOpened.Y);
            TileButtonMatrix[secondOpened.X, secondOpened.Y].Image = GameManager.sr_ValueDictionary[key].Image;
            SecondChoiceButton           = TileButtonMatrix[secondOpened.X, secondOpened.Y];
            SecondChoiceButton.BackColor = Player2Name.BackColor;
            ComputerTurnState            = eComputerTurnState.EndTurn;
        }
コード例 #5
0
        private void firstTileChoosenByComputer()
        {
            Point firstOpened = new Point();
            int   key;

            ComputerPlayer.ZeroAndUpdateRevealedTiles(MemoryBoard);
            firstOpened = ComputerPlayer.ChooseFirstTile(MemoryBoard);
            key         = MemoryBoard.GetKey(firstOpened.X, firstOpened.Y);
            TileButtonMatrix[firstOpened.X, firstOpened.Y].Image = GameManager.sr_ValueDictionary[key].Image;
            FirstChoiceButton           = TileButtonMatrix[firstOpened.X, firstOpened.Y];
            FirstChoiceButton.BackColor = Player2Name.BackColor;
            ComputerTurnState           = eComputerTurnState.SecondTileToChoose;
        }