Exemplo n.º 1
0
        void Answer(object sender, RoutedEventArgs e)
        {
            Highscore score    = new Highscore(momentalniscore);
            var       tag      = ((Button)sender).Tag;
            string    x        = tag.ToString();
            int       kliknuto = Int32.Parse(x);

            if (kliknuto == 1)
            {
                if (vyhra == 1)
                {
                    level++;
                    StopZvukLevely();
                    CreateQaA();
                }
                else
                {
                    if (level < 5)
                    {
                        GG();
                    }
                    else
                    {
                        this.Close();
                        score.Show();
                    }
                }
            }
            if (kliknuto == 2)
            {
                if (vyhra == 2)
                {
                    level++;
                    StopZvukLevely();
                    CreateQaA();
                }
                else
                {
                    if (level < 5)
                    {
                        GG();
                    }
                    else
                    {
                        this.Close();
                        score.Show();
                    }
                }
            }
            if (kliknuto == 3)
            {
                if (vyhra == 3)
                {
                    level++;
                    StopZvukLevely();
                    CreateQaA();
                }
                else
                {
                    if (level < 5)
                    {
                        GG();
                    }
                    else
                    {
                        this.Close();
                        score.Show();
                    }
                }
            }
            if (kliknuto == 4)
            {
                if (vyhra == 4)
                {
                    level++;
                    StopZvukLevely();
                    CreateQaA();
                }
                else
                {
                    if (level < 5)
                    {
                        GG();
                    }
                    else
                    {
                        this.Close();
                        score.Show();
                    }
                }
            }
        }
Exemplo n.º 2
0
        void CreateQaA()
        {
            if (level == 5)
            {
                momentalniscore = 50000;
            }
            if (level == 8)
            {
                momentalniscore = 500000;
            }
            //Výhra
            if (level == 11)
            {
                Highscore score = new Highscore(momentalniscore);
                momentalniscore = 5000000;
                this.Close();
                score.Show();
            }

            if (level < 11)
            {
                if (File.Exists(pathQaA))
                {
                    if (ukol.Count != 0)
                    {
                        //Otázky, Odpovědi a obtížnost
                        //ukol.Add(new QaA("Jaký je rok?", "2010", "2020", "2015", "2018", 1));

                        //string jsonToFile = JsonConvert.SerializeObject(ukol, settings);
                        //File.WriteAllText(pathQaA, jsonToFile);

                        //Tohle ne
                        procenta1.Visibility = Visibility.Hidden;
                        procenta2.Visibility = Visibility.Hidden;
                        procenta3.Visibility = Visibility.Hidden;
                        procenta4.Visibility = Visibility.Hidden;

                        //Vše zobrazit
                        A.Visibility        = Visibility.Visible;
                        odpoved1.Visibility = Visibility.Visible;
                        A1.IsEnabled        = true;
                        B.Visibility        = Visibility.Visible;
                        odpoved2.Visibility = Visibility.Visible;
                        A2.IsEnabled        = true;
                        C.Visibility        = Visibility.Visible;
                        odpoved3.Visibility = Visibility.Visible;
                        A3.IsEnabled        = true;
                        D.Visibility        = Visibility.Visible;
                        odpoved4.Visibility = Visibility.Visible;
                        A4.IsEnabled        = true;

                        if (CheckForInternetConnection() == false)
                        {
                            InternetHLP.Content = "50/50" + (char)0xB2;
                        }
                        //Skore
                        Scoreboard();

                        //Zvuky
                        ZvukLevely();

                        //Vypsání
                        var shoda    = ukol.Where(n => n.obtiznost == level).ToList();
                        int rotazka  = r.Next(shoda.Count());
                        int rodpoved = r.Next(0, 4);
                        rodpoved2      = rodpoved;
                        otazka.Content = shoda[rotazka].otazka;

                        if (rodpoved == 0)
                        {
                            odpoved1.Content = shoda[rotazka].odpoved1;
                            odpoved2.Content = shoda[rotazka].odpoved2;
                            odpoved3.Content = shoda[rotazka].odpoved3;
                            odpoved4.Content = shoda[rotazka].odpoved4;
                            vyhra            = 4;
                        }
                        if (rodpoved == 1)
                        {
                            odpoved1.Content = shoda[rotazka].odpoved4;
                            odpoved2.Content = shoda[rotazka].odpoved1;
                            odpoved3.Content = shoda[rotazka].odpoved2;
                            odpoved4.Content = shoda[rotazka].odpoved3;
                            vyhra            = 1;
                        }
                        if (rodpoved == 2)
                        {
                            odpoved1.Content = shoda[rotazka].odpoved3;
                            odpoved2.Content = shoda[rotazka].odpoved4;
                            odpoved3.Content = shoda[rotazka].odpoved1;
                            odpoved4.Content = shoda[rotazka].odpoved2;
                            vyhra            = 2;
                        }
                        if (rodpoved == 3)
                        {
                            odpoved1.Content = shoda[rotazka].odpoved2;
                            odpoved2.Content = shoda[rotazka].odpoved3;
                            odpoved3.Content = shoda[rotazka].odpoved4;
                            odpoved4.Content = shoda[rotazka].odpoved1;
                            vyhra            = 3;
                        }
                    }
                    else
                    {
                        string jsonToFile = JsonConvert.SerializeObject(ukol, settings);
                        File.WriteAllText(pathQaA, jsonToFile);
                    }
                }
                else
                {
                    string jsonToFile = JsonConvert.SerializeObject(ukol, settings);
                    File.WriteAllText(pathQaA, jsonToFile);
                }
            }
        }