예제 #1
0
        public static void TalkTo(NonPlayerCharacter npc, DialogParser parser)
        {
            Console.Clear();
            NpcDialogPart  npc_part;
            HeroDialogPart hero_part;

            npc_part = npc.StartTalking();

            string choice;
            int    part_index;

            while (true)
            {
                Console.WriteLine("{0}: {1}", npc.name, parser.ParseDialog(npc_part));

                if (npc_part.answers.Count == 0)
                {
                    Console.WriteLine("KONIEC");
                    Console.WriteLine();
                    Console.WriteLine("Wciśnij Enter...");
                    Console.ReadLine();
                    return;
                }
                for (int i = 0; i < npc_part.answers.Count; i++)
                {
                    Console.WriteLine("[{0}] {1}", i + 1, parser.ParseDialog(npc_part.answers[i]));
                }

                while (true)
                {
                    choice = Console.ReadLine();

                    if (!Int32.TryParse(choice, out part_index) || part_index > npc_part.answers.Count)
                    {
                        Console.WriteLine("Niepoprawna opcja. Sprobuj jeszcze raz.");
                    }
                    else
                    {
                        hero_part = npc_part.answers[part_index - 1];

                        if (hero_part.answers.Count == 0)
                        {
                            Console.WriteLine("KONIEC");
                            Console.WriteLine();
                            Console.WriteLine("Wciśnij Enter...");
                            Console.ReadLine();
                            return;
                        }
                        npc_part = hero_part.answers[0];
                        break;
                    }
                }
            }
        }
예제 #2
0
        public static void Init(Location location) //dialogs and npcs initialization
        {
            parser = new DialogParser(hero);

            NpcDialogPart n1 = new NpcDialogPart("Witaj, czy możesz mi pomóc dostać się do innego miasta?");

            HeroDialogPart h1_1 = new HeroDialogPart("Tak, chętnie pomogę.");
            HeroDialogPart h1_2 = new HeroDialogPart("Nie, nie pomogę, żegnaj.");

            n1.answers.Add(h1_1);
            n1.answers.Add(h1_2);

            NpcDialogPart n2 = new NpcDialogPart("Dziękuję! W nagrodę otrzymasz ode mnie 100 sztuk złota.");

            h1_1.answers.Add(n2);

            HeroDialogPart h2_1 = new HeroDialogPart("Dam znać jak będę gotowy.");
            HeroDialogPart h2_2 = new HeroDialogPart("100 sztuk złota to za mało!");

            n2.answers.Add(h2_1);
            n2.answers.Add(h2_2);

            NpcDialogPart n3 = new NpcDialogPart("Niestety nie mam więcej. Jestem bardzo biedny.");

            h2_2.answers.Add(n3);

            HeroDialogPart h3_1 = new HeroDialogPart("OK, może być 100 sztuk złota.");
            HeroDialogPart h3_2 = new HeroDialogPart("W takim razie radź sobie sam.");

            n3.answers.Add(h3_1);
            n3.answers.Add(h3_2);

            NpcDialogPart n4 = new NpcDialogPart("Dziękuję.");

            h3_1.answers.Add(n4);


            NpcDialogPart n5 = new NpcDialogPart("Witaj, mam do sprzedarzy różne rzeczy. Czego szukasz?");

            HeroDialogPart h5_1 = new HeroDialogPart("Potrzebuję zbroję.");
            HeroDialogPart h5_2 = new HeroDialogPart("Nic nie potrzebuję.");

            n5.answers.Add(h5_1);
            n5.answers.Add(h5_2);

            NpcDialogPart n6 = new NpcDialogPart("Mam skórzaną.");

            h5_1.answers.Add(n6);

            HeroDialogPart h6_1 = new HeroDialogPart("Nie, chcę lamelkową.");
            HeroDialogPart h6_2 = new HeroDialogPart("Ile kosztuje?");

            n6.answers.Add(h6_1);
            n6.answers.Add(h6_2);

            NpcDialogPart n7 = new NpcDialogPart("300 sztuk złota. A razem z kapturem za 350.");

            h6_2.answers.Add(n7);

            HeroDialogPart h7_1 = new HeroDialogPart("Dobrze, kupuję wszystko.");
            HeroDialogPart h7_2 = new HeroDialogPart("Biorę bez kaptura.");

            n7.answers.Add(h7_1);
            n7.answers.Add(h7_2);

            NpcDialogPart n8 = new NpcDialogPart("Fajny wybór.");

            h7_2.answers.Add(n8);

            NpcDialogPart n9 = new NpcDialogPart($"Hej czy to Ty jesteś tym słynnym {HERONAME} – pogromcą smoków?”");

            HeroDialogPart h9_1 = new HeroDialogPart($"Tak, jestem {HERONAME}.");
            HeroDialogPart h9_2 = new HeroDialogPart("Nie.");

            n9.answers.Add(h9_1);
            n9.answers.Add(h9_2);


            location.Add_npc(new NonPlayerCharacter("Cain", n1));
            location.Add_npc(new NonPlayerCharacter("Warriv", n5));
            location.Add_npc(new NonPlayerCharacter("Deckard", n9));

            Console.ReadLine();
        }