示例#1
0
        private void UpdateUI()
        {
            UpdateAttemptsLeft();
            if (_backend.IsGameWon())
            {
                ResetGame();
                MessageBox.Show("Congratulations. You won!");
            }
            else if (_backend.IsGameOver())
            {
                ResetGame();
                MessageBox.Show("Awww. You lost..");
            }
            string word = _backend.GetWord();

            string[] guessedChars = _backend.GetGuesses();
            string   wordUI       = "";

            foreach (var c in word)
            {
                if (guessedChars.Any(s => s.Equals(c.ToString())))
                {
                    wordUI += " " + c;
                }
                else
                {
                    wordUI += " _";
                }
            }
            labelWord.Content = wordUI;
            UpdatePicture();
        }