Exemplo n.º 1
0
        // When a button is clicked and is colored, we will check all 4 buttons in a turn in order to see if we can click the check guess button
        public void ColorButton_Clicked(object sender, ColorChosenEventArgs e)
        {
            ColoredGameButton theButtonThatWasClicked = (ColoredGameButton)sender;

            // If the button that we clicked on belong to this turn we need to check all guesses
            if (m_TurnNumber == e.TurnNumber)
            {
                for (int i = 0; i < m_NumberOfColorsTheUserGuesses; i++)
                {
                    // If we chose a color that was already chosen in the same turn, choose a different color

                    if (theButtonThatWasClicked.ButtonCollor == UserGuess[i].ButtonCollor && theButtonThatWasClicked != UserGuess[i])
                    {
                        theButtonThatWasClicked.PerformClick();
                    }
                }

                for (int i = 0; i < m_NumberOfColorsTheUserGuesses; i++)
                {
                    // if not all 4 guessButtons are colored, no need to activate checkGuessButton
                    if (!UserGuess[i].IsColored)
                    {
                        return;
                    }
                }
                // If we have chosen 4 uniqe colors, activate checkGuessbutton
                m_CheckGuessButton.TurnOn();
            }
        }