Exemple #1
0
        private void Game_KeyPress(object sender, KeyPressEventArgs e)
        {
            char tmpKey = Char.ToLower(e.KeyChar);

            bool found = false;

            for (int i = 0; i < choosenWord.Length; i++)
            {
                if (choosenWord[i] == tmpKey)
                {
                    found = true;
                    pictures[i].Show();
                    picturesStart[i].Hide();
                }
            }

            if (found)
            {
                bool flag = false;
                int br = charCount(choosenWord, tmpKey);
                int br2 = charCount(pomosen, tmpKey);

                for (int x = 0; x < pomosen.Length; x++)
                {
                    if (pomosen[x] == tmpKey)
                    {
                        flag = true;
                    }
                }

                if (!flag)
                {
                    for (int i = 0; i < br; i++)
                    {
                        pomosen = pomosen + tmpKey;
                    }
                    score += (int)tmpKey * 100 + 20;
                    flag = false;
                }
                else if (flag)
                    MessageBox.Show("You already tried that letter!");

                int pom3 = 0;
                for (int i = 0; i < choosenWord.Length; i++)
                {
                    if (choosenWord[i] == ' ')
                        pom3++;
                }

                if (pomosen.Length - 1 == choosenWord.Length - pom3)
                {
                    Highscores high = new Highscores(oppener, this, score);
                    high.Show();
                }
            }
            else
            {
                bool flag = false;

                for (int x = 0; x < pomosenZaGreska.Length; x++)
                {
                    if (pomosenZaGreska[x] == tmpKey)
                    {
                        flag = true;
                        MessageBox.Show("You already tried that letter!");
                    }
                }

                if (!flag)
                {
                    pomosenZaGreska = pomosenZaGreska + tmpKey;
                    score -= (int)tmpKey * 20 + 20;
                    flag = false;
                }

                if (pomosenZaGreska.Length - 1 == 1)
                    head.Show();
                else if (pomosenZaGreska.Length - 1 == 2)
                    pictureBox1.Show();
                else if (pomosenZaGreska.Length - 1 == 3)
                    pictureBox2.Show();
                else if (pomosenZaGreska.Length - 1 == 4)
                    pictureBox3.Show();
                else if (pomosenZaGreska.Length - 1 == 5)
                    pictureBox4.Show();
                else if (pomosenZaGreska.Length - 1 == 6)
                {
                    pictureBox5.Show();

                    MessageBox.Show("Game Over!");
                    oppener.Show();
                    oppener2.Close();
                    this.Close();
                }
            }
        }
Exemple #2
0
        private void Game_KeyPress(object sender, KeyPressEventArgs e)
        {
            char tmpKey = Char.ToLower(e.KeyChar);

            bool found = false;

            for (int i = 0; i < choosenWord.Length; i++)
            {
                if (choosenWord[i] == tmpKey)
                {
                    found = true;
                    pictures[i].Show();
                    picturesStart[i].Hide();
                }
            }

            if (found)
            {
                bool flag = false;
                int  br   = charCount(choosenWord, tmpKey);
                int  br2  = charCount(pomosen, tmpKey);

                for (int x = 0; x < pomosen.Length; x++)
                {
                    if (pomosen[x] == tmpKey)
                    {
                        flag = true;
                    }
                }

                if (!flag)
                {
                    for (int i = 0; i < br; i++)
                    {
                        pomosen = pomosen + tmpKey;
                    }
                    score += (int)tmpKey * 100 + 20;
                    flag   = false;
                }
                else if (flag)
                {
                    MessageBox.Show("You already tried that letter!");
                }

                int pom3 = 0;
                for (int i = 0; i < choosenWord.Length; i++)
                {
                    if (choosenWord[i] == ' ')
                    {
                        pom3++;
                    }
                }

                if (pomosen.Length - 1 == choosenWord.Length - pom3)
                {
                    Highscores high = new Highscores(oppener, this, score);
                    high.Show();
                }
            }
            else
            {
                bool flag = false;

                for (int x = 0; x < pomosenZaGreska.Length; x++)
                {
                    if (pomosenZaGreska[x] == tmpKey)
                    {
                        flag = true;
                        MessageBox.Show("You already tried that letter!");
                    }
                }

                if (!flag)
                {
                    pomosenZaGreska = pomosenZaGreska + tmpKey;
                    score          -= (int)tmpKey * 20 + 20;
                    flag            = false;
                }

                if (pomosenZaGreska.Length - 1 == 1)
                {
                    head.Show();
                }
                else if (pomosenZaGreska.Length - 1 == 2)
                {
                    pictureBox1.Show();
                }
                else if (pomosenZaGreska.Length - 1 == 3)
                {
                    pictureBox2.Show();
                }
                else if (pomosenZaGreska.Length - 1 == 4)
                {
                    pictureBox3.Show();
                }
                else if (pomosenZaGreska.Length - 1 == 5)
                {
                    pictureBox4.Show();
                }
                else if (pomosenZaGreska.Length - 1 == 6)
                {
                    pictureBox5.Show();

                    MessageBox.Show("Game Over!");
                    oppener.Show();
                    oppener2.Close();
                    this.Close();
                }
            }
        }