Ejemplo n.º 1
0
 private void StartGame(IEnumerable<string[]> lista, int iloscslow)
 {
     Random rand = new Random();
     currentSlowa = lista
         .Take(iloscslow)
         .OrderBy((x) => rand.Next())
         .ToList();
     ktoreSlowo = 0;
     var tc = new TekstComponent(currentSlowa[0][0], "Dalej", currentSlowa[0][1]);
     Fade(tc);
     tc.ButtonClicked += NextPhase;
 }
Ejemplo n.º 2
0
        private void NextPhase(object o, EventArgs e)
        {
            switch (CurrentPhase)
            {
                case Phase.Poczatek:
                    {
                        evaluation = new Evaluation {typBadania = (CurrentControl as WyborBadaniaControl).Wynik};
                        var tc = MakeTekst("Wstep", null);
                        Fade(tc);
                        CurrentPhase = Phase.Wstep;
                        tc.ButtonClicked += NextPhase;
                    }
                    break;
                case Phase.Wstep:
                    {
                        TekstComponent tc;
                        switch (evaluation.typBadania)
                        {
                            case WyborBadaniaControl.TypBadania.Badanie5:
                                CurrentPhase = Phase.Zadanie1_Opis;
                                IleSlow = 5;
                                break;
                            case WyborBadaniaControl.TypBadania.Badanie10:
                                CurrentPhase = Phase.Zadanie1_Opis;
                                IleSlow = 10;
                                break;
                            case WyborBadaniaControl.TypBadania.Badanie15:
                                CurrentPhase = Phase.Zadanie1_Opis;
                                IleSlow = 15;
                                break;
                            case WyborBadaniaControl.TypBadania.BadanieK:
                                CurrentPhase = Phase.Zadanie2_Opis;
                                IleSlow = 15;
                                break;
                        }
                        Fade(tc = MakeTekst("Zadanie1", IleSlow));
                        tc.ButtonClicked += NextPhase;
                    }
                    break;
                case Phase.Zadanie1_Opis:
                    {
                        MakeWordList(slowa1, IleSlow);
                        CurrentPhase = Phase.Zadanie1_ListaSlow;
                    }
                    break;
                case Phase.Zadanie1_ListaSlow:
                    {
                        StartGame(slowa1, IleSlow);
                        CurrentPhase = Phase.Zadanie1_Gra;
                    }
                    break;
                case Phase.Zadanie1_Gra:
                    {
                        PlayGame(Phase.Zadanie1_Opis, () =>
                            {
                                var tc2 = MakeTekst("Przerwa", null);
                                Fade(tc2);
                                CurrentPhase = Phase.Przerwa;
                                StartTimer(new TimeSpan(0, 2, 0), () => NextPhase(o, e));
                            });
                    }
                    break;
                case Phase.Przerwa:
                    {
                        TekstComponent tc;
                        IleSlow = 15;
                        Fade(tc = MakeTekst("Zadanie2", 15));
                        tc.ButtonClicked += NextPhase;
                        CurrentPhase = Phase.Zadanie2_Opis;
                    }
                    break;
                case Phase.Zadanie2_Opis:
                    {
                        MakeWordList(slowa2, 15);
                        evaluation.StartTimeEval();
                        CurrentPhase = Phase.Zadanie2_ListaSlow;
                    }
                    break;
                case Phase.Zadanie2_ListaSlow:
                    {
                        StartGame(slowa2, 15);
                        CurrentPhase = Phase.Zadanie2_Gra;
                    }
                    break;
                case Phase.Zadanie2_Gra:
                    {
                        PlayGame(Phase.Zadanie2_Opis, () =>
                            {
                                var tc = MakeTekst("Zadanie3", null);
                                Fade(tc);
                                tc.ButtonClicked += NextPhase;
                                CurrentPhase = Phase.Zadanie3_Opis;
                                evaluation.EndTimeEval();
                            });
                    }
                    break;
                case Phase.Zadanie3_Opis:
                    {
                        StartTimer(new TimeSpan(0,2,0), () =>
                            {
                                var tc = MakeTekst("Zadanie4", evaluation.typBadania == WyborBadaniaControl.TypBadania.BadanieK?1:2);
                                Fade(tc);
                                CurrentPhase = Phase.Zadanie4_Opis;
                                tc.ButtonClicked += NextPhase;
                            });
                        CurrentPhase = Phase.Zadanie3_Gra;
                        NextPhase(o, e);
                    }
                    break;
                case Phase.Zadanie3_Gra:
                    {
                        Random rand = new Random();
                        int min = int.Parse(xnav.SelectSingleNode("TekstyBadania/Zadanie3/Min/text()").Value);
                        int max = int.Parse(xnav.SelectSingleNode("TekstyBadania/Zadanie3/Max/text()").Value);

                        string[] sgns = {"-", "+", "*"};

                        string query = String.Format("{0} \t {1} \t {2} \t =", rand.Next(min, max), sgns[rand.Next(sgns.Length)], rand.Next(min, max));

                        var tc = new TekstComponent(query, "Dalej", "0");
                        Fade(tc);
                        tc.ButtonClicked += NextPhase;
                    }
                    break;
                case Phase.Zadanie4_Opis:
                    {
                        var rand = new Random();
                        var tc = new KoncowyTest(slowa2.OrderBy((st) => rand.Next()).ToList());
                        StartTimer(new TimeSpan(0, 2, 0), () =>
                        {
                            var tkon = MakeTekst("Koniec", null);
                            Fade(tkon);
                            evaluation.CorrectFraction = tc.GetPercentage();
                            evaluation.SaveToFile("raport");
                            CurrentPhase = Phase.Koniec;
                        });
                        Fade(tc);
                    }
                    break;
                case Phase.Koniec:
                    break;
            }
        }
Ejemplo n.º 3
0
 private void PlayGame(Phase currPhase, Action onFinished)
 {
     var tc = (CurrentControl as TekstComponent);
     if (!tc.Validate())
     {
         CurrentPhase = currPhase;
         NextPhase(null, null);
         return;
     }
     if (ktoreSlowo == IleSlow - 1)
     {
         onFinished();
     }
     else
     {
         ktoreSlowo++;
         var tc2 = new TekstComponent(currentSlowa[ktoreSlowo][0], "Dalej", currentSlowa[ktoreSlowo][1]);
         Fade(tc2);
         tc2.ButtonClicked += NextPhase;
     }
 }
Ejemplo n.º 4
0
        private void MakeWordList(IEnumerable<string[]> lista, int iloscslow)
        {
            int maxlen = lista.Take(iloscslow)
                              .Select((s) => s[0].Length)
                              .Max();

            string pary =
                lista.Take(iloscslow)
                      .Select((s) => s[0] + (new string(' ', maxlen - s[0].Length+5)) + "-\t" + s[1])
                      .Aggregate((s1, s2) => s1 + "\n" + s2);
            var tc = new TekstComponent(pary, "Dalej");
            Fade(tc);
            tc.ButtonClicked += NextPhase;
        }