public string ParseDialog(IDialogPart dialogPart) { const string str = "#HERONAME#"; var text = dialogPart.GetText(); return(text.Contains(str) ? text.Replace(str, _hero.HeroName) : text); }
private static void PerformTalk(NPC npc) { IDialogPart dialogPart = npc.StartTalking(); Console.WriteLine("Rozmawiasz z " + npc.Name); while (dialogPart != null) { Console.Clear(); List <IDialogPart> heroPartLists = dialogPart.PossibleStatments(); if (dialogPart.GetType() == typeof(NpcDialogPart)) { Console.WriteLine(parser.ParseDialog(dialogPart)); if (heroPartLists == null) { break; } for (int i = 0; i < heroPartLists.Count; i++) { Console.WriteLine("[" + i + "] " + parser.ParseDialog(dialogPart.PossibleStatments()[i])); } ConsoleKeyInfo clicked; int x = int.MaxValue; do { clicked = Console.ReadKey(); Int32.TryParse(clicked.KeyChar.ToString(), out x); } while (x > heroPartLists.Count); dialogPart = heroPartLists[x]; } else if (dialogPart.GetType() == typeof(HeroDialogPart)) { if (heroPartLists == null) { break; } dialogPart = dialogPart.PossibleStatments()[0]; } else { Console.WriteLine("Fatal Error Diff Type Expected."); break; } } locationList.Find(x => x.Name == "AMines Of Moria").IsUnlocked = true; Console.WriteLine("<Koniec>. Kliknij aby wrócić do ekranu lokacji..."); Console.ReadKey(); }
private static IDialogPart ReadDialogPart(ref string[] parts, ref int current) { IDialogPart result = null; string[] divided = parts[current].Split(RIGHT_BRACKET, System.StringSplitOptions.None); switch (divided[0]) { case LABEL_DIALOG: Debug.Log("Invalid XML label, <dialog> only allowed in toplevel"); break; case LABEL_MESSAGE: result = new DialogMessage(divided[1]); break; case LABEL_CHOICE: //divided = divided[1].Split(ENDLINES, System.StringSplitOptions.RemoveEmptyEntries); break; case LABEL_QUEST: //divided = divided[1].Split(ENDLINES, System.StringSplitOptions.RemoveEmptyEntries); break; case LABEL_DELAY: //divided = divided[1].Split(ENDLINES, System.StringSplitOptions.RemoveEmptyEntries); break; case LABEL_TELEPORT: //divided = divided[1].Split(ENDLINES, System.StringSplitOptions.RemoveEmptyEntries); break; default: Debug.Log("Unrecognised tag: <" + divided[0] + ">"); break; } return(result); }
/* * BuildDialogue1 builds shown dialogue: * * NPC: „Witaj, czy możesz mi pomóc dostać się do innego miasta?” * Hero: „Tak, chętnie pomogę” * NPC: „Dziękuję! W nagrodę otrzymasz ode mnie 100 sztuk złota”. * Hero: „Dam znać jak będę gotowy” <KONIEC> * Hero: „100 sztuk złota to za mało!” * NPC: „Niestety nie mam więcej. Jestem bardzo biedny”. * Hero: „OK, może być 100 sztuk złota.” * NPC: „Dziękuję.” <KONIEC> * Hero: „W takim razie radź sobie sam.” <KONIEC> * Hero: „Nie, nie pomogę, żegnaj.” <KONIEC> */ private NpcDialogPart BuildDialogue1() { List <IDialogPart> heroPartLists = new List <IDialogPart>(); NpcDialogPart oneNpcPart = new NpcDialogPart("„Dziękuję.”", null); IDialogPart oneHeroPart = (IDialogPart) new HeroDialogPart("„OK, może być 100 sztuk złota.”", oneNpcPart); heroPartLists.Add(oneHeroPart); oneHeroPart = (IDialogPart) new HeroDialogPart("„W takim razie radź sobie sam.”", null); heroPartLists.Add(oneHeroPart); oneNpcPart = new NpcDialogPart("„Niestety nie mam więcej. Jestem bardzo biedny”", new List <IDialogPart>(heroPartLists)); oneHeroPart = (IDialogPart) new HeroDialogPart("„100 sztuk złota to za mało!”", oneNpcPart); heroPartLists.Clear(); heroPartLists.Add(oneHeroPart); oneHeroPart = (IDialogPart) new HeroDialogPart("„Dam znać jak będę gotowy”", null); heroPartLists.Add(oneHeroPart); oneNpcPart = new NpcDialogPart("„Dziękuję! W nagrodę otrzymasz ode mnie 100 sztuk złota”", new List <IDialogPart>(heroPartLists)); oneHeroPart = (IDialogPart) new HeroDialogPart("„Tak, chętnie pomogę”", oneNpcPart); heroPartLists.Clear(); heroPartLists.Add(oneHeroPart); oneHeroPart = (IDialogPart) new HeroDialogPart("„Nie, nie pomogę, żegnaj.”", null); heroPartLists.Add(oneHeroPart); oneNpcPart = new NpcDialogPart("„Witaj, czy możesz mi pomóc dostać się do innego miasta?”", new List <IDialogPart>(heroPartLists)); return(oneNpcPart); }
public string ParseDialog(IDialogPart dialog_part) { return(dialog_part.Part); }
public string ParseDialog(IDialogPart dialogPart) { return(dialogPart.statement.Replace("#HERONAME#", hero.name)); }
public String ParseDialog(IDialogPart dialogPart) { String message = dialogPart.Message(); return(message.Replace("{ImięPostaci}", mainCharacter.name)); }