示例#1
0
        // Choses random wordGame object from list
        private void setWordRandom()
        {
            bool setWord = true;

            do
            {
                setWord = true;
                if (wordsList.Count == usedWords.Count) // If all words have been used, end game
                {
                    endGame = true;
                    break;
                }

                // Gets a random word from list
                wordGame wg = (wordGame)wordsList[Program.GetRandomNumber(0, wordsList.Count)];
                mainWord      = wg;
                lblHint1.Text = wg.getHint1();
                word          = wg.getWord();

                if (usedWords.Contains(wg.getWord()))
                {
                    setWord = false;
                }
            } while (setWord == false); // Will continue to loop if a word that has already been used is selected
        }
示例#2
0
        // btnGo click event
        private void btnGo_click(object sender, EventArgs e)
        {
            if (endGame == true)
            {
                System.Windows.Forms.Application.Exit();
            }
            else
            {
                bool notEmpty = true;
                // Checks if text boxes are empty
                for (int i = 0; i < inputBoxesList.Count; i++)
                {
                    TextBox tb = (TextBox)inputBoxesList[i];

                    if (String.IsNullOrEmpty(tb.Text))
                    {
                        notEmpty = false;
                    }
                }

                // Will check each text box to see if it contains the correct letter, only if
                // all the text boxes are not empty
                if (notEmpty == true)
                {
                    bool isCorrect = true;

                    for (int i = 0; i < word.Length; i++)
                    {
                        TextBox tb = (TextBox)inputBoxesList[i];

                        if (tb.Text[0] != mainWord.getWord()[i])
                        {
                            isCorrect = false;
                        }
                    }

                    if (isCorrect == true)
                    {
                        usedWords.Add(mainWord.getWord());
                        addPoints();
                        newRound();
                    }
                    else
                    {
                        showHint();
                    }
                }
                else
                {
                    showHint();
                }

                centerContorls();
            }
        }