private void InitializeConversations()
        {
            allConversations = new Dictionary<string, Conversation>();

            var conversationAsset = Resources.Load("Conversations") as TextAsset;

            var doc = new XmlDocument();
            doc.LoadXml(conversationAsset.text);

            var conversationNodes = doc.FirstChild.ChildNodes.OfType<XmlNode>().Where(n => n.Name == "conversation");

            foreach (var conversationXml in conversationNodes)
            {
                var lines = new List<ConversationItem>();

                foreach (XmlNode line in conversationXml.ChildNodes)
                {
                    if (line.Name == "line")
                        lines.Add(LineItem.FromXml(line));
                    else if (line.Name == "choice")
                        lines.Add(ChoiceItem.FromXml(line));
                }

                var conversation = new Conversation(lines.ToArray());

                allConversations.Add(conversationXml.Attributes.GetNamedItem("name").Value, conversation);
            }
        }
Example #2
0
        public void StartConversation(Conversation conversation)
        {
            conversation.Restart();

            this.conversation = conversation;
        }