private void ClearEntities() { dialogueEntity1 = null; dialogueEntity2 = null; player = null; enemy = null; }
public List <DialogueEntity> FindConnectedDialogues(DialogueEntity dialogue) { List <DialogueEntity> dialogues = new List <DialogueEntity>(); dialogues.Add(dialogue); foreach (var item in CurrentTree.dialogue_relations.data) { if (item.Key == dialogue.id) { FindConnectedDialogues(FindById(nodes, item.Value).entity).ForEach(childDialogue => { dialogues.Add(childDialogue); }); } } foreach (var option in dialogue.options) { if (CurrentTree.IsOptionExtended(option)) { FindConnectedDialogues(FindById(nodes, CurrentTree.option_relations.data[option.id]).entity).ForEach(childDialogue => { dialogues.Add(childDialogue); }); } } return(dialogues); }
protected void InitializeDialogue(DialogueEntity dialogue) { List <string> texts; if (dialogue.textContinuity) { texts = new List <string>(dialogue.texts); } else { texts = new List <string>() { dialogue.texts[random.Next(0, dialogue.texts.Count)] } }; CurrentDialogue currentDialogue = new CurrentDialogue(dialogueTree, dialogue, texts, variables); listenerRegistry.DialogueGeneralListeners["on_initialization"].ForEach(action => { action(this, currentDialogue); }); if (listenerRegistry.DialogueSpecificListeners["on_initialization"].ContainsKey(dialogue.id)) { listenerRegistry.DialogueSpecificListeners["on_initialization"][dialogue.id].ForEach(action => { action(this, currentDialogue); }); } this.currentDialogue = currentDialogue; DialogueReadyListenersCall(dialogue); return; }
public DialogueNode Initialize(DialogueEntity entity) { this.entity = entity; this.Window = originalRect = new Rect(entity.window.x, entity.window.y, entity.window.width, entity.window.height); return(this); }
public CurrentDialogue(DialogueTreeEntity tree, DialogueEntity dialogue, List <string> selectedTexts, Dictionary <string, string> variables) { this.currentTextIndex = 0; this.tree = tree; this.dialogue = dialogue; //this.originalText = this.text = selectedText; this.originalTexts = this.texts = new List <string>(selectedTexts); this.InitializeSelections(); this.variables = variables; this.ApplyVariables(variables); }
public void SetDialogueEntities(MovableEntity d1, MovableEntity d2) { player = d1; enemy = d2; dialogueEntity1 = d1.gameObject.GetComponent <DialogueEntity>(); dialogueEntity2 = d2.gameObject.GetComponent <DialogueEntity>(); d1.isTalking = true; d2.isTalking = true; d1.SetDirection(Direction.IDLE); d2.SetDirection(Direction.IDLE); StartDialogue(); }
protected void DialogueReadyListenersCall(DialogueEntity dialogue) { listenerRegistry.DialogueGeneralListeners["on_ready"].ForEach(action => { action(this, currentDialogue); }); if (listenerRegistry.DialogueSpecificListeners["on_ready"].ContainsKey(dialogue.id)) { listenerRegistry.DialogueSpecificListeners["on_ready"][dialogue.id].ForEach(action => { action(this, currentDialogue); }); } }
protected void ExtendDialogue(DialogueNode origin) { var dialogue = new DialogueEntity() { id = UnityEngine.Random.Range(0, 1000000).ToString(), window = new WindowEntity() { x = origin.Window.x + 220f, y = origin.Window.y, width = 150f, height = 100 } }; nodes.Add((new DialogueNode()).Initialize(dialogue)); CurrentTree.RelateDialogue(origin.entity.id, dialogue.id); }
protected override void InitializeTree(string category) { if (treeInitialized) { return; } OriginalName = ""; CurrentTree = new DialogueTreeEntity(); if (category != "") { CurrentTree.name = category.TrimEnd('/') + "/"; } // start dialogue node var node = (new DialogueTreeNode()).Initialize(CurrentTree); //windows.Add(node); dialogueTreeNode = node; // initialize first dialogue. DialogueEntity dialogue = new DialogueEntity() { id = UnityEngine.Random.Range(0, 1000000).ToString(), window = new WindowEntity() { x = 250f, y = 10f, width = 150f, height = 100 } }; nodes.Add((new DialogueNode()).Initialize(dialogue)); CurrentTree.SetInitialDialogue(dialogue); treeInitialized = true; }
protected DialogueNode CreateDialogue() { var dialogue = new DialogueEntity() { id = UnityEngine.Random.Range(0, 1000000).ToString(), window = new WindowEntity() { x = mousePos.x - 7f, y = mousePos.y - 7f, width = 150f, height = 100 } }; //var node = CreateInstance<DialogueNode>().Initialize(dialogue); var node = (new DialogueNode()).Initialize(dialogue); nodes.Add(node); return(node); }