Example #1
0
        //Генерира random збор од листата од зборови, пушта тајмер за зборот
        private void GenerateDisplayWord()
        {
            Timer.Stop();
            TimeElapsed = 0;
            Timer.Start();

            if (Words.Count != 0)
            {
                int index = new Random().Next(0, Words.Count);
                Word = Words.ElementAt(index);
            }
            else
            {
                if (Game.Categories.Count >= 5)
                {
                    MessageBox.Show($"{LanguageSettings.YouWonTheGameMessage}{Game.Difficulty}!", LanguageSettings.CongratulationsMessage);
                }
                else
                {
                    string categories = string.Empty;
                    foreach (var category in Game.Categories)
                    {
                        categories += category.ToString() + " ";
                    }

                    DialogResult result = MessageBox.Show(LanguageSettings.CategoriesFinishedMessage, LanguageSettings.WellDoneMessage, MessageBoxButtons.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        LoadWords(true);
                        GenerateDisplayWord();
                    }
                    else
                    {
                        NewGameForm newGameForm = new NewGameForm();
                        newGameForm.Show();
                        this.Close();
                    }
                }
            }

            string ctg = string.Empty;

            if (Word.Category == Category.General)
            {
                ctg = LanguageSettings.CategoriesGeneral;
            }
            else if (Word.Category == Category.Sport)
            {
                ctg = LanguageSettings.CategoriesSport;
            }
            else if (Word.Category == Category.Science)
            {
                ctg = LanguageSettings.CategoriesScience;
            }
            else if (Word.Category == Category.Movies)
            {
                ctg = LanguageSettings.CategoriesMovies;
            }
            else
            {
                ctg = LanguageSettings.CategoriesGeography;
            }

            CategoryLabel.Text = $"{LanguageSettings.CategoryLabel}: {ctg}";

            Mistakes = 0;
            WrongoLettersLabel.Text = string.Empty;

            var word = Word.Name.ToUpper()[0].ToString();

            for (var i = 0; i < Word.Name.Length - 1; i++)
            {
                word += " _";
            }
            WordToGuessLabel.Text = word;

            foreach (Button c in EnglishKeyboard.Controls)
            {
                c.Enabled = true;
            }

            foreach (Button c in MacedonianKeyboard.Controls)
            {
                c.Enabled = true;
            }

            hangmanHead.Visible     = false;
            hangmanBody.Visible     = false;
            hangmanLeftArm.Visible  = false;
            hangmanRightArm.Visible = false;
            hangmanLeftLeg.Visible  = false;
            hangmanRightLeg.Visible = false;
        }