public void show(NPC npc, DialogueTopic topic = null) { _npc = npc; setData(_npc); Text.Text = ""; //List<DialogueTopic> dialogueTopics = GameManager.Instance.DialogueTopicLibrary.getTopicsByNPC(_npc); //topicListShow(dialogueTopics); topicListShow(_npc); optionListClear(); if (topic == null) { DialogueTopic greetingTopic = GameManager.Instance.DialogueTopicLibrary.getGreetingTopicByNPC(_npc); if (greetingTopic != null) { topicShow(greetingTopic); } } else { topicShow(topic); } gameObject.SetActive(true); }
public Dialogue(string modFileName, DialogueTopic topic, IDictionary <string, DialogueResponse> responses, OnAddResponse onAdd, OnRemoveResponse onRemove) { this.modFileName = modFileName; Topic = topic; this.responses = responses; this.onAdd = onAdd; this.onRemove = onRemove; //Console.WriteLine($"{modFileName}/{topic.Name}"); //foreach (var response in responses.Values) //{ // Console.WriteLine($"{response.PreviousIdentifier} <- {response.Identifier} -> {response.NextIdentifier}"); //} if (responses.Count > 0) { firstIdentifier = (from response in responses.Values where response.PreviousIdentifier.Length == 0 || !responses.ContainsKey(response.PreviousIdentifier) select response.Identifier).First(); lastIdentifier = (from response in responses.Values where response.NextIdentifier.Length == 0 || !responses.ContainsKey(response.NextIdentifier) select response.Identifier).First(); } else { firstIdentifier = lastIdentifier = ""; } }
DialogueTopic GetTopic(string name) { if (dialogue.ContainsKey(name)) { return(dialogue[name]); } DialogueTopic newTopic = new DialogueTopic(name); dialogue.Add(name, newTopic); return(newTopic); }
public DialogueStage Stage(string stageId, DialogueTopic defaultTopic) { string[] keyparts = stageId.Split(new char[] { '.' }, 2); if (keyparts.Length != 2) { throw new GameException("Invalid Stage ID"); } if (String.IsNullOrEmpty(keyparts[0])) { return(this[defaultTopic].stages[keyparts[1]]); } return(this[keyparts[0]].stages[keyparts[1]]); }
void OnAddDialogueResponse(string modFileName, DialogueTopic topic, IList <DialogueResponse> responses) { var modFile = modFiles[modFileName]; var registry = recordItemRegistry[modFileName]; var addIndex = modFile.GetDialogueAddIndex(dialogueByIdAndFile[new GameItemKey(modFileName, topic.Name)].Item1); foreach (var response in responses) { var record = response.CreateRecord(); registry.Add(new Tuple <Record, TES3GameItem>(record, response)); modFile.InsertRecordAt(addIndex++, record); } }
public void topicShow(DialogueTopic topic) { try { _currentTopic = topic; DialogueStage stage = GameManager.Instance.DialogueLineCache[topic].StartStage(); stageShow(stage); } catch (Exception e) { textShow("ERROR: The requested Dialoguestage can't be found"); Debug.LogError(e); } }
static int GetItemIndex(IList <GameItemVersion <Dialogue> > versions, DialogueTopic topic) { var index = -1; foreach (var current in versions) { ++index; if (current.Item.Topic == topic) { return(index); } } return(-1); }
public Dialogue CreateDialogue(string modFileName, DialogueTopic topic) { var record = topic.CreateRecord(); var modFile = modFiles[modFileName]; topic.IdChanged += OnIdChange; modFile.InsertRecordAt(modFile.GetAddIndex("DIAL"), record); recordItemRegistry[modFileName].Add(new Tuple <Record, TES3GameItem>(record, topic)); var dialogue = new Dialogue(modFileName, topic, new Dictionary <string, DialogueResponse>(), OnAddDialogueResponse, OnRemoveDialogueResponse); dialogueByIdAndFile.Add(new GameItemKey(modFileName, topic.Name), new Tuple <Record, Dialogue>(record, dialogue)); dialogueVersionsById[topic.Name].Add(new GameItemVersion <Dialogue>(modFileName, dialogue)); dialogueByModFile[modFileName].Add(dialogue); return(dialogue); }
public DialogueStages this[DialogueTopic key] { get => this[key.ID]; }
public void Load(ModFile modFile) { if (modFiles.ContainsKey(modFile.Name)) { throw new ArgumentException($"Mod file already loaded: {modFile.Name}"); } // Cache mod file. modFiles.Add(modFile.Name, modFile); // Create Record <-> TES3GameItem relationship. var regItems = new List <Tuple <Record, TES3GameItem> >(); recordItemRegistry.Add(modFile.Name, regItems); DialogueTopic currentTopic = null; IDictionary <string, DialogueResponse> currentResponses = null; foreach (var record in modFile) { // Create Item TES3GameItem item; if (record.Name == "CELL") { if (CellUtils.IsInterior(record)) { item = new InteriorCell(record); } else { item = new ExteriorCell(record); } } else { if (!GameItemConstructors.ContainsKey(record.Name)) { throw new ArgumentException($"Unrecognized record type: {record.Name}"); } var constructor = GameItemConstructors[record.Name]; item = (TES3GameItem)constructor.Invoke(new Record[] { record }); } // Cache individual Record <-> TES3GameItem relationship. regItems.Add(new Tuple <Record, TES3GameItem>(record, item)); if (item.GetType() == typeof(DialogueTopic)) { if (currentTopic != null) { var dialogue = new Dialogue(modFile.Name, currentTopic, currentResponses, OnAddDialogueResponse, OnRemoveDialogueResponse); dialogueVersionsById[currentTopic.Name].Add(new GameItemVersion <Dialogue>(modFile.Name, dialogue)); dialogueByModFile[modFile.Name].Add(dialogue); dialogueByIdAndFile.Add(new GameItemKey(modFile.Name, currentTopic.Name), new Tuple <Record, Dialogue>(record, dialogue)); } currentTopic = (DialogueTopic)item; currentResponses = new Dictionary <string, DialogueResponse>(); item.IdChanged += OnIdChange; } else if (item.GetType() == typeof(DialogueResponse)) { if (currentTopic == null) { throw new InvalidOperationException(); } var dialogueItem = (DialogueResponse)item; currentResponses.Add(dialogueItem.Identifier, dialogueItem); } else { if (currentTopic != null) { var dialogue = new Dialogue(modFile.Name, currentTopic, currentResponses, OnAddDialogueResponse, OnRemoveDialogueResponse); dialogueVersionsById[currentTopic.Name].Add(new GameItemVersion <Dialogue>(modFile.Name, dialogue)); dialogueByModFile[modFile.Name].Add(dialogue); dialogueByIdAndFile.Add(new GameItemKey(modFile.Name, currentTopic.Name), new Tuple <Record, Dialogue>(record, dialogue)); currentTopic = null; currentResponses = null; } // Handle common caching. HandleCommonCache(modFile.Name, item); } } }
public void setTopic(DialogueTopic topic) { _topic = topic; Text.text = _topic.Title.Text(); }