void ActivateConversationElement(ConversationElement convoElement) { MoveConversationsAround(); switch (convoElement.thisActor) { case RunnerGameActors.Player: if (playerTopConvoObj.activeInHierarchy == true || sproutTopConvoObj.activeInHierarchy == true) { playerBotConvoObj.SetActive(true); playerBotConvoText.text = convoElement.thisMessage; } else { playerTopConvoObj.SetActive(true); playerTopConvoText.text = convoElement.thisMessage; } break; case RunnerGameActors.Sprout: if (playerTopConvoObj.activeInHierarchy == true || sproutTopConvoObj.activeInHierarchy == true) { sproutBotConvoObj.SetActive(true); sproutBotConvoText.text = convoElement.thisMessage; } else { sproutTopConvoObj.SetActive(true); sproutTopConvoText.text = convoElement.thisMessage; } break; } }
private void ProcessNode(ConversationElement element, IConversationReader reader) { Debug.Log("Processing Element " + element.type); currentElement = element; switch (element.type) { case ConversationElementType.Text: reader.DisplayText(reader.KeywordReplace(element.text)); break; case ConversationElementType.Set: conversationVariables.Add(element.setKey, element.setValue); break; case ConversationElementType.Choice: List <string> keywordedChoices = new List <string>(); foreach (string choice in element.choices) { keywordedChoices.Add(reader.KeywordReplace(choice)); } reader.DisplayChoice(keywordedChoices, GetChoiceResponse); waitingOnChoice = true; return; case ConversationElementType.Branch: for (int i = 0; i < element.branchVariables.Count; i++) { //i is the branch we're checking bool metCondtions = true; for (int j = 0; j < element.branchVariables[i].Count; j++) { //j is the condition of branch i that we're checking if (conversationVariables.ContainsKey(element.branchVariables[i][j])) { if (conversationVariables[element.branchVariables[i][j]] != element.branchConditions[i][j]) { metCondtions = false; } } } if (metCondtions) { nextElement = elements[element.branchResults[i]]; break; } } //no branch conditions met, so continue to use the next element break; } }
public void StartTree(ConversationElement element, IConversationReader reader) { currentReader = reader; ProcessNode(element, reader); if (currentElement.next <= -1) { Debug.Log("Tree is one node long"); currentReader.EndConversation(); } else if (currentElement.next >= elements.Count) { Debug.LogError("Out of range next element"); } else { nextElement = elements[currentElement.next]; } }
private ConversationElement CreateConversationGUI(VisualElement root, NovelAsset asset, ConversationRow conversation) { var contentElems = new List <ContentElement>(); var conversationElem = new ConversationElement { userData = contentElems, text = conversation.Id }; var languages = new List <string>(asset.Languages); var languagesPopup = new LanguagePopup("Language Id", languages, 0); languagesPopup.RegisterValueChangedCallback(OnChangeLanguage); conversationElem.Add(languagesPopup); foreach (var kv in conversation.Dialogues) { CreateDialogueGUI(conversationElem.Content, conversation, kv.Value, contentElems, languages[0]); } root.Add(conversationElem); return(conversationElem); }
public void NextNode() { if (nextElement == null) { Debug.LogWarning("Conversation ended with null next element " + this); currentReader.EndConversation(); } else if (nextElement.type == ConversationElementType.End) { currentReader.EndConversation(); } else { ProcessNode(nextElement, currentReader); if (currentElement.next >= elements.Count) { Debug.LogError("Out of range next element"); } else { nextElement = elements[currentElement.next]; } } }