Advertisement
AndrewRosyaev

Dialog.cs

May 17th, 2016
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Xml.Serialization;
  4. using System.IO;
  5.  
  6. [XmlRoot("dialogue")]
  7. public class Dialog
  8. {
  9.     [XmlElement("node")]
  10.     public Node[] nodes;
  11.  
  12.     public static Dialog Load(TextAsset _xml)
  13.     {
  14.         XmlSerializer serializer = new XmlSerializer (typeof(Dialog));
  15.         StringReader reader = new StringReader (_xml.text);
  16.         Dialog dial = serializer.Deserialize (reader) as Dialog;
  17.         return dial;
  18.     }
  19. }
  20.  
  21. [System.Serializable]
  22. public class Node
  23. {
  24.     [XmlElement("npctext")]
  25.     public string NpcText;
  26.  
  27.     [XmlArray("answers")]
  28.     [XmlArrayItem("answer")]
  29.     public Answer[] answers;
  30. }
  31.  
  32. [System.Serializable]
  33. public class Answer
  34. {
  35.     [XmlAttribute("tonode")]
  36.     public int nextNode;
  37.     [XmlElement("text")]
  38.     public string text;
  39.     [XmlElement("dialend")]
  40.     public string end;
  41.  
  42.  
  43.     [XmlAttribute("questvalue")]
  44.     public int QuestValue;
  45.     [XmlAttribute("needquestvalue")]
  46.     public int NeedQuestValue;
  47.     [XmlElement("questname")]
  48.     public string QuestName;
  49.  
  50.  
  51.     [XmlAttribute("rewardgold")]
  52.     public int RewardGold;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement