public DialogueDictionary cloneDictionary() { DialogueDictionary clonedDictionary = new DialogueDictionary(); foreach (KeyValuePair <int, Dialogue> pair in this) { clonedDictionary[pair.Key] = pair.Value; } return(clonedDictionary); }
private void Awake() { if (dialogueNodes != null) { return; } dialogueNodes = new DialogueDictionary(); var dialogueNode = CreateInstance <DialogueNode>().Setup(); dialogueNodes.Add(dialogueNode.name, dialogueNode); startDialogueNodeName = dialogueNode.name; }
public void Clear() { startDialogueNodeName = null; foreach (var node in dialogueNodes.Values) { #if UNITY_EDITOR AssetDatabase.RemoveObjectFromAsset(node); #endif } dialogueNodes = new DialogueDictionary(); }
void parseTextToScriptObject() { if (i >= contentDivided.Length) { return; } string currentString = this.contentDivided [i]; // get type of the text TEXT_CONTENT currentContentType = getContentType(currentString); Debug.Log("current type is: " + currentContentType.ToString() + "for index: " + i); switch (currentContentType) { case TEXT_CONTENT.DAY: // create new day // if there is previous day, store it then create new day // try to parse date // store data of the new day // go to next string if (currentDay != null) { this.currentDay.populateConversationnodes(conversationDictionary.cloneDictionary()); this.currentDay.populateChoiceNodes(choiceDictionary.cloneDictionary()); this.currentDay.setNextDay(this.dayIndex + 1); this.newScript.DaysList.Add(currentDay); } this.currentDay = new Day(); this.currentDay.setStartingNode(0); this.conversationDictionary = new DialogueDictionary(); this.choiceDictionary = new ChoiceDictionary(); string date = currentString.Split(':') [1].Trim(); if (date != "NA") { Debug.Log(date); string[] dateArray = date.Split(' '); Debug.Log(dateArray.Length); this.currentDay.setDate(int.Parse(dateArray [0]), int.Parse(dateArray [1]), int.Parse(dateArray [2])); } break; case TEXT_CONTENT.BACKGROUND: //if no node, create new dialogue, keep //if there is node, store node, create new dialogue, keep if (isFirstNodeCreated) { Debug.Log("current content index: " + i); addNodeToDictionary(); } reinitializeDialogue(); break; case TEXT_CONTENT.SFX: // if no node, create new dialogue, keep // if there is node, store node, create new dialogue, keep if (isFirstNodeCreated) { addNodeToDictionary(); } reinitializeDialogue(); Match matchingResult = this.sfxRegex.Match(currentString); //obtain sfx -- Not supported yet string sfxName = matchingResult.Groups [1].ToString(); Debug.Log("sound effect name is : " + sfxName); //sfx might have additionalDialogue string additionalDialogue = matchingResult.Groups [2].ToString(); additionalDialogue = additionalDialogue.TrimStart(); if (additionalDialogue.Length > 0) { Debug.Log("adding dialogue to list of string"); this.currentDialogue.setCharacter(Narrator); this.stringTextDialogues.Add(additionalDialogue); } else { Debug.Log("not adding"); } break; case TEXT_CONTENT.SPRITE_HIDE: break; case TEXT_CONTENT.SPRITE_SHOW: break; case TEXT_CONTENT.SPEAKING: string[] nameAndDialogue = currentString.Split(':'); string name = nameAndDialogue [0]; string dialogue = nameAndDialogue [1]; Character currentlySpeakingCharacter; if (name == shioSpeaking_String) { currentlySpeakingCharacter = Shio; } else if (name == grahamSpeaking_String) { currentlySpeakingCharacter = Graham; } else { if (!characterArchive.TryGetValue(name, out currentlySpeakingCharacter)) { currentlySpeakingCharacter = new Character(); currentlySpeakingCharacter.setName(name); this.characterArchive.Add(name, currentlySpeakingCharacter); } } if (lastUsedCharacter != null && !lastUsedCharacter.Equals(currentlySpeakingCharacter)) { addNodeToDictionary(); reinitializeDialogue(); } if (!isFirstNodeCreated) { reinitializeDialogue(); } this.stringTextDialogues.Add(dialogue); this.currentDialogue.setCharacter(currentlySpeakingCharacter); this.lastUsedCharacter = currentlySpeakingCharacter; break; case TEXT_CONTENT.SPEAKING_NO_NAME: if (lastUsedCharacter != null && !lastUsedCharacter.Equals(Narrator)) { addNodeToDictionary(); reinitializeDialogue(); } if (!isFirstNodeCreated) { reinitializeDialogue(); } this.stringTextDialogues.Add(currentString); lastUsedCharacter = Narrator; this.currentDialogue.setCharacter(Narrator); break; case TEXT_CONTENT.TUTORIAL_BOX: break; } }
void initializeTestingEnvironment() { Character testCharacter = new Character(); testCharacter.setName(this.testCharacterName); Character narratorCharacter = new Character(); narratorCharacter.setName(string.Empty); Day testDay = new Day(); testDay.setStartingNode(10); DialogueDictionary testDialogue = new DialogueDictionary(); ChoiceDictionary testChoice = new ChoiceDictionary(); BranchDictionary testBranch = new BranchDictionary(); //// list of dialogues nodes//// DialoguePreAction preAction0 = new DialoguePreAction(); preAction0.addNewPreAction(new KeyValuePair <DialoguePreAction.ACTION, int> (DialoguePreAction.ACTION.FADE_IN, -1)); preAction0.addNewPreAction(new KeyValuePair <DialoguePreAction.ACTION, int> (DialoguePreAction.ACTION.SHOW_DIALOGUE_BAR, 0)); preAction0.addNewPreAction(new KeyValuePair <DialoguePreAction.ACTION, int> (DialoguePreAction.ACTION.PLAY_SFX, (int)SoundManagerScript.SFX_TYPE.PLANE_SFX)); preAction0.addNewPreAction(new KeyValuePair <DialoguePreAction.ACTION, int>(DialoguePreAction.ACTION.PLAY_BGM, (int)SoundManagerScript.BGM_TYPE.BGM_WHATEVER)); List <string> dialogue0List = new List <string> { "> Airport, Food Court.", "> You've finished checking in and have your boarding pass with you.", "> You are now waiting for Graham to come." }; Dialogue dialogue0 = new Dialogue(); dialogue0.setListOfDialogues(dialogue0List); dialogue0.setPreAction(preAction0); dialogue0.setCharacter(narratorCharacter); dialogue0.setNextNodeID(0); List <string> dialogue1List = new List <string> { "Hmm... I still can't believe that he is really going to come see me off...", "I mean, it's not a bad thing.", }; Dialogue dialogue1 = new Dialogue(); dialogue1.setListOfDialogues(dialogue1List); ConditionalNextNode nextNode1 = new ConditionalNextNode(); nextNode1.setConditional(false); nextNode1.setDefaultNextNode(1); dialogue1.setCharacter(testCharacter); dialogue1.setNextNodeID(1); List <string> dialogue2List = new List <string> { "uuu... I am nervous...", "I hope this time around it will be better than our last date...", "Does he even actually consider it a date? Or is he just being friendly and offer to help me find the figurine that I want..", "Am I getting ahead of myself? is it just me that think he is interested in me?" }; Dialogue dialogue2 = new Dialogue(); dialogue2.setListOfDialogues(dialogue2List); dialogue2.setCharacter(testCharacter); dialogue2.setNextNodeID(2); List <string> dialogue3List = new List <string> { "What if he think I am weird after that outing.", "He did say he enjoy our time together though...", "But, what if he was just being kind... What if he actually think otherwise!?", "Shio... Why did you even decide to get a kid's seat for lunch!", "Stupid! STUPID!", "...", "Huh?", "Oh no! He's already here!?", "What should I tell him..." }; Dialogue dialogue3 = new Dialogue(); dialogue3.setListOfDialogues(dialogue3List); ConditionalNextNode nextNode3 = new ConditionalNextNode(); nextNode3.setConditional(false); dialogue3.setCharacter(testCharacter); dialogue3.setNextNodeID(5); Choice choice1 = new Choice(); ChoiceEffect c10 = new ChoiceEffect(3, 0); ChoiceEffect c20 = new ChoiceEffect(4, 0); KeyValuePair <string, ChoiceEffect> c1 = new KeyValuePair <string, ChoiceEffect> ("Don't answer immediately", c10); KeyValuePair <string, ChoiceEffect> c2 = new KeyValuePair <string, ChoiceEffect> ("Tell him where you currently are", c20); List <KeyValuePair <string, ChoiceEffect> > listOfChoices1 = new List <KeyValuePair <string, ChoiceEffect> > { c1, c2 }; choice1.populateChoices(listOfChoices1); List <string> dialogue4List = new List <string> { "Calm down... Calm Down...", "Now, where were we?" }; Dialogue dialogue4 = new Dialogue(); dialogue4.setListOfDialogues(dialogue4List); ConditionalNextNode nextNode4 = new ConditionalNextNode(); dialogue4.setCharacter(testCharacter); dialogue4.setNextNodeID(5); List <string> dialogue5List = new List <string> { "Hummm... I hope I look okay...", "But... He does like to wear fancy stuff.", "No matter what I do, I'll probably look like a plebian next to him." }; Dialogue dialogue5 = new Dialogue(); dialogue5.setListOfDialogues(dialogue5List); dialogue5.setCharacter(testCharacter); dialogue5.setNextNodeID(-1); testDialogue.Add(10, dialogue0); testDialogue.Add(0, dialogue1); testDialogue.Add(1, dialogue2); testDialogue.Add(2, dialogue3); testDialogue.Add(3, dialogue4); testDialogue.Add(4, dialogue5); testChoice.Add(5, choice1); testDay.populateConversationnodes(testDialogue); testDay.populateBranchNodes(testBranch); testDay.populateChoiceNodes(testChoice); this.currentDay = testDay; this.currentDayID = 0; this.player.yourProgression.setCurrentDay(this.currentDayID); }
public void populateConversationnodes(DialogueDictionary convoNodes) { this.conversationNodes = convoNodes; }