Exemplo n.º 1
0
 private void NewGame(bool level)
 {
     word        = Dico.NewWord(level);
     falseNumber = 0;
     Initialisation(word);
     btnlist.RealeaseBtn();
     textBlock.Text = "Already Tested : ";
 }
Exemplo n.º 2
0
        private void bt_Click(object sender, RoutedEventArgs e)
        {
            Button clickedButton = (Button)sender;

            btnlist.Add(clickedButton);

            char letter = clickedButton.Content.ToString()[0];

            textBlock.Text += letter;
            textBlock.Text += ", ";

            BtManager.TurnOff(clickedButton);

            if (Dico.IsGood(word, letter))
            {
                int index = 0;
                while (index != -1)
                {
                    index = word.IndexOf(letter, index);
                    StringBuilder temp = new StringBuilder();
                    temp.Append(textWord.Text);

                    if (index != -1)
                    {
                        temp.Remove(index, 1);
                        temp.Insert(index, letter);
                        textWord.Text = temp.ToString().ToUpper();
                        index++;
                    }
                }
                if (textWord.Text.IndexOf('?') == -1)
                {
                    EndGame(true);
                }
            }
            else
            {
                falseNumber++;
                ImageSource hangIm = new BitmapImage(new Uri(string.Format("ms-appx:///Assets/{0}.jpg", falseNumber)));
                image.Source = hangIm;
                if (falseNumber == 10)
                {
                    EndGame(false);
                }
            }
        }