Ejemplo n.º 1
0
        private static void Nulovani()
        {
            Console.Clear();
            obtiznost   = 0;
            nevyskyt    = 0;
            pocet_radku = 0;
            g           = 0;
            pismeno     = '\0';
            Uhodnute uhodnute_pismeno = new Uhodnute(0);

            Console.ForegroundColor = ConsoleColor.White;
        }
Ejemplo n.º 2
0
        private bool prazdne_misto; //Ještě neuhodnuté písmeno.

        public void CyklusHry()     //Hlavní cyklus hry.
        {
            Zaplneni();             //Zaplněění pole demaska.
            Picture obesenec = new Picture();

            while (PrazdneMisto() == true)   //Cyklus se bud opakovat, dokud bude v poli demaska prázsné místo.
            {
                PrvniCast();                 //Vypsání úvodu.
                if (nevyskyt == (obtiznost)) //Jestliže hráč udělal maximální počet chyb, ukončí se cyklus hry.
                {
                    PrvniCast();
                    kontrola_vstupu = true;
                    obesenec.Obrazek(); //Načtení obrázku.
                    Console.Beep(3000, 500); Console.Beep(2831, 500); Console.Beep(2672, 500); Console.Beep(2522, 1000);
                    break;
                }
                kontrola_vstupu = true;      //Tato proměnná zajistí, že se obrázek se bude vykreslovat pouze při uhodnutí chybného písmena.
                obesenec.Obrazek();          //Načtení obrázku.
                Uhodnute uhodnute_pismeno = new Uhodnute(1);
                GetLetter();                 //Uživatelský vstup - písmeno.
                Overeni();                   //Ověření, zda se písmeno nachází ve slově.
                obesenec.Obrazek();          //Načtení obrázku.
                Console.WriteLine();
                if (PrazdneMisto() == false) //Jestliže hráč uhodl celé slovo, ukončí se cyklus hry.
                {
                    break;
                }
            }

            if (PrazdneMisto() == false) //Jestliže hráč uhodl slovo, vypíše se výherní hláška.
            {
                PrvniCast();
                kontrola_vstupu = true;
                obesenec.Obrazek();
                Uhodnute uhodnute_pismeno = new Uhodnute(1);
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Vyhráli jste!");
                Console.Beep(1500, 500); Console.Beep(1890, 500); Console.Beep(2247, 500); Console.Beep(3000, 800);
            }
        }
Ejemplo n.º 3
0
        public void Obrazek()
        {
            ChybnePismeno();
            switch (obtiznost) //Volba obrázků podle obtížnosti, načtení cesty k určitému obrázku.
            {
            case 8:
                switch (nevyskyt)
                {
                case 0:
                    Galerie = Path.GetFullPath("Texty/Obrazek0.txt");
                    Galerie = Path.GetFullPath("Texty/Obrazek0.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek0.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 1:
                    Galerie = Path.GetFullPath("Texty/Obrazek1.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek1.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 2:
                    Galerie = Path.GetFullPath("Texty/Obrazek2.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek2.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 3:
                    Galerie = Path.GetFullPath("Texty/Obrazek3.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek3.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 4:
                    Galerie = Path.GetFullPath("Texty/Obrazek4.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek4.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 5:
                    Galerie = Path.GetFullPath("Texty/Obrazek5.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek5.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 6:
                    Galerie = Path.GetFullPath("Texty/Obrazek6.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek6.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 7:
                    Galerie = Path.GetFullPath("Texty/Obrazek7.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek7.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 8:
                    Galerie = Path.GetFullPath("Texty/Obrazek8.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek8.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                default:
                    Galerie = Path.GetFullPath("Texty/Chyba.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Chyba.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;
                }
                break;

            case 5:
                switch (nevyskyt)
                {
                case 0:
                    Galerie = Path.GetFullPath("Texty/Obrazek0.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek0.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 1:
                    Galerie = Path.GetFullPath("Texty/Obrazek1.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek1.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 2:
                    Galerie = Path.GetFullPath("Texty/Obrazek3.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek3.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 3:
                    Galerie = Path.GetFullPath("Texty/Obrazek5.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek5.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 4:
                    Galerie = Path.GetFullPath("Texty/Obrazek6.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek6.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 5:
                    Galerie = Path.GetFullPath("Texty/Obrazek8.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek8.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                default:
                    Galerie = Path.GetFullPath("Texty/Chyba.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Chyba.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;
                }
                break;

            case 3:
                switch (nevyskyt)
                {
                case 0:
                    Galerie = Path.GetFullPath("Texty/Obrazek0.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek0.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 1:
                    Galerie = Path.GetFullPath("Texty/Obrazek3.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek3.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 2:
                    Galerie = Path.GetFullPath("Texty/Obrazek5.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek5.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                case 3:
                    Galerie = Path.GetFullPath("Texty/Obrazek8.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Obrazek8.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;

                default:
                    Galerie = Path.GetFullPath("Texty/Chyba.txt");
                    if (File.Exists(Galerie))
                    {
                        Galerie = Path.GetFullPath("Texty/Chyba.txt");
                    }
                    else
                    {
                        ChybovaHlaska();
                    }
                    break;
                }
                break;
            }

            using (var obraz = new System.IO.StreamReader(Galerie)) //Začátek načítání obrázku.
            {
                switch (obtiznost)                                  //Ukončení hry a prozrazení slova podle obtížnosti.
                {
                case 8:
                    if (nevyskyt == 8)
                    {
                        Prohra();
                    }
                    break;

                case 5:
                    if (nevyskyt == 5)
                    {
                        Prohra();
                    }
                    break;

                case 3:
                    if (nevyskyt == 3)
                    {
                        Prohra();
                    }
                    break;
                }

                void Prohra() //Vypsání proherní hlášky a hádaného slova.
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    while ((Galerie = obraz.ReadLine()) != null)
                    {
                        Console.WriteLine(Galerie);
                    }
                    Console.ForegroundColor = ConsoleColor.White;
                    Uhodnute uhodnute_pismeno = new Uhodnute(1);

                    Console.WriteLine();
                    Console.Write("Prohrál jsi, člověče! Měl jsi uhodnout slovo ");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write(slovo);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("!!!");
                }

                switch (obtiznost) //Volba barvy obrázku
                {
                case 8:
                    switch (nevyskyt)
                    {
                    case 0:
                        Console.ForegroundColor = ConsoleColor.White;
                        break;

                    case 1:
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;

                    case 2:
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;

                    case 3:
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;

                    case 4:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;

                    case 5:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;

                    case 6:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;

                    case 7:
                        Console.ForegroundColor = ConsoleColor.Red;
                        break;

                    case 8:
                        Console.ForegroundColor = ConsoleColor.Red;
                        break;
                    }
                    break;

                case 5:
                    switch (nevyskyt)
                    {
                    case 0:
                        Console.ForegroundColor = ConsoleColor.White;
                        break;

                    case 1:
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;

                    case 2:
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;

                    case 3:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;

                    case 4:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;

                    case 5:
                        Console.ForegroundColor = ConsoleColor.Red;
                        break;
                    }
                    break;

                case 3:
                    switch (nevyskyt)
                    {
                    case 0:
                        Console.ForegroundColor = ConsoleColor.White;
                        break;

                    case 1:
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;

                    case 2:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;

                    case 3:
                        Console.ForegroundColor = ConsoleColor.Red;
                        break;
                    }
                    break;
                }
                while ((Galerie = obraz.ReadLine()) != null) //Načtení obrázku.
                {
                    Console.WriteLine(Galerie);
                }
                Console.ForegroundColor = ConsoleColor.White;
            }
        }