public Reaction LoadConversation(TextReader reader, string startNode = null) { if (string.IsNullOrEmpty(startNode)) startNode = "start"; XmlSerializer serializer = new XmlSerializer (typeof(Conversation)); Conversation conversation = serializer.Deserialize (reader) as Conversation; Node node = null; if (conversation.TryGetNode (startNode, _gameInterface, out node)) { Reaction reaction = new Reaction(node, conversation, _gameInterface, _langs); return reaction; } return null; }
/// <summary> /// Tries to get the best reaction. The best reaction is the last one which fullfil all conditions /// in its group. /// </summary> /// <returns> /// The get best reaction. /// </returns> /// <param name='reaction'> /// If set to <c>true</c> reaction. /// </param> public bool TryGetBestReaction(out Reaction reaction) { reaction = null; Group group = null; if (_conversation.TryGetGroup(_node, out group) == false) return false; Node latest = null; foreach (var node in group) if (node.TestConditions (_gameInterface)) latest = node; if (latest != null) { reaction = ReactionFromNode(latest); return true; } return false; }