private void ContinueToNextNode(DialogueOption selectedOption) { _currentNode.SetNodeCompleted(); if (selectedOption.ConditionToSet != string.Empty) { DialogueConditionManager.SharedInstance.SetConditionState(selectedOption.ConditionToSet, true); } if (selectedOption.ConditionToCancel != string.Empty) { DialogueConditionManager.SharedInstance.SetConditionState(selectedOption.ConditionToCancel); } if (selectedOption.TargetName == string.Empty) { _currentNode = null; return; } if (!_mapDialogueNodes.ContainsKey(selectedOption.TargetName)) { Debug.LogError("Cannot find target node " + selectedOption.TargetName); Debug.Break(); } _currentNode = _mapDialogueNodes[selectedOption.TargetName]; }
private void ContinueToNextNode() { _currentNode.SetNodeCompleted(); if (_currentNode.ListTargetCondition.Count > 0 && !_currentNode.TargetNodeConditionsSatisfied()) { _currentNode = null; return; } _currentNode = _currentNode.Target; }
private void SetEntryNode() { var list = new List <QSBDialogueNode>(); list.AddRange(_mapDialogueNodes.Values); for (var i = list.Count - 1; i >= 0; i--) { if (list[i].EntryConditionsSatisfied()) { _currentNode = list[i]; return; } } Debug.LogWarning("CharacterDialogueTree " + _characterName + " no EntryConditions satisfied. Did you forget to add <EntryCondition>DEFAULT</EntryCondition> to a node?"); }
private bool LoadXml() { try { _mapDialogueNodes.Clear(); _listOptionNodes.Clear(); var sharedInstance = DialogueConditionManager.SharedInstance; var xelement = XDocument.Parse(OWUtilities.RemoveByteOrderMark(_xmlCharacterDialogueAsset)).Element("DialogueTree"); var xelement2 = xelement.Element("NameField"); if (xelement2 == null) { _characterName = ""; } else { _characterName = xelement2.Value; } foreach (var xelement3 in xelement.Elements("DialogueNode")) { var dialogueNode = new QSBDialogueNode(); if (xelement3.Element("Name") != null) { dialogueNode.Name = xelement3.Element("Name").Value; } else { Debug.LogWarning("Missing name on a Node"); } var randomize = xelement3.Element("Randomize") != null; dialogueNode.DisplayTextData = new DialogueText(xelement3.Elements("Dialogue"), randomize); var xelement4 = xelement3.Element("DialogueTarget"); if (xelement4 != null) { dialogueNode.TargetName = xelement4.Value; } var enumerable = xelement3.Elements("EntryCondition"); if (enumerable != null) { foreach (var xelement5 in enumerable) { dialogueNode.ListEntryCondition.Add(xelement5.Value); if (!sharedInstance.ConditionExists(xelement5.Value)) { sharedInstance.AddCondition(xelement5.Value); } } } var enumerable2 = xelement3.Elements("DialogueTargetShipLogCondition"); if (enumerable2 != null) { foreach (var xelement6 in enumerable2) { dialogueNode.ListTargetCondition.Add(xelement6.Value); } } foreach (var xelement7 in xelement3.Elements("SetCondition")) { dialogueNode.ConditionsToSet.Add(xelement7.Value); } var xelement8 = xelement3.Element("SetPersistentCondition"); if (xelement8 != null) { dialogueNode.PersistentConditionToSet = xelement8.Value; } var xelement9 = xelement3.Element("DisablePersistentCondition"); if (xelement9 != null) { dialogueNode.PersistentConditionToDisable = xelement9.Value; } var xelement10 = xelement3.Element("RevealFacts"); if (xelement10 != null) { var enumerable3 = xelement10.Elements("FactID"); if (enumerable3 != null) { var list = new List <string>(); foreach (var xelement11 in enumerable3) { list.Add(xelement11.Value); } dialogueNode.DBEntriesToSet = new string[list.Count]; for (var i = 0; i < list.Count; i++) { dialogueNode.DBEntriesToSet[i] = list[i]; } } } var list2 = new List <DialogueOption>(); var xelement12 = xelement3.Element("DialogueOptionsList"); if (xelement12 != null) { var enumerable4 = xelement12.Elements("DialogueOption"); if (enumerable4 != null) { foreach (var xelement13 in enumerable4) { var dialogueOption = new DialogueOption { Text = OWUtilities.CleanupXmlText(xelement13.Element("Text").Value, false) }; dialogueOption.SetNodeId(dialogueNode.Name, _characterName); var xelement14 = xelement13.Element("DialogueTarget"); if (xelement14 != null) { dialogueOption.TargetName = xelement14.Value; } if (xelement13.Element("RequiredCondition") != null) { dialogueOption.ConditionRequirement = xelement13.Element("RequiredCondition").Value; if (!sharedInstance.ConditionExists(dialogueOption.ConditionRequirement)) { sharedInstance.AddCondition(dialogueOption.ConditionRequirement); } } foreach (var xelement15 in xelement13.Elements("RequiredPersistentCondition")) { dialogueOption.PersistentCondition.Add(xelement15.Value); } if (xelement13.Element("CancelledCondition") != null) { dialogueOption.CancelledRequirement = xelement13.Element("CancelledCondition").Value; if (!sharedInstance.ConditionExists(dialogueOption.CancelledRequirement)) { sharedInstance.AddCondition(dialogueOption.CancelledRequirement); } } foreach (var xelement16 in xelement13.Elements("CancelledPersistentCondition")) { dialogueOption.CancelledPersistentRequirement.Add(xelement16.Value); } foreach (var xelement17 in xelement13.Elements("RequiredLogCondition")) { dialogueOption.LogConditionRequirement.Add(xelement17.Value); } if (xelement13.Element("ConditionToSet") != null) { dialogueOption.ConditionToSet = xelement13.Element("ConditionToSet").Value; if (!sharedInstance.ConditionExists(dialogueOption.ConditionToSet)) { sharedInstance.AddCondition(dialogueOption.ConditionToSet); } } if (xelement13.Element("ConditionToCancel") != null) { dialogueOption.ConditionToCancel = xelement13.Element("ConditionToCancel").Value; if (!sharedInstance.ConditionExists(dialogueOption.ConditionToCancel)) { sharedInstance.AddCondition(dialogueOption.ConditionToCancel); } } list2.Add(dialogueOption); _listOptionNodes.Add(dialogueOption); } } } dialogueNode.ListDialogueOptions = list2; _mapDialogueNodes.Add(dialogueNode.Name, dialogueNode); } var list3 = new List <QSBDialogueNode>(); list3.AddRange(_mapDialogueNodes.Values); for (var j = 0; j < list3.Count; j++) { var dialogueNode2 = list3[j]; var targetName = dialogueNode2.TargetName; if (targetName != "") { if (_mapDialogueNodes.ContainsKey(targetName)) { dialogueNode2.Target = _mapDialogueNodes[targetName]; } else { Debug.LogError("Target Node: " + targetName + " does not exist", this); } } else { dialogueNode2.Target = null; } } } catch (Exception ex) { Debug.LogError("XML Error in CharacterDialogueTree!\n" + ex.Message, this); return(false); } return(true); }