Пример #1
0
        public static Dictionary <string, Frame> LoadDialogue(string dialogueName)
        {
            TextAsset ta = Resources.Load <TextAsset>("dData/" + dialogueName);
            JObject   jo = JObject.Parse(ta.text);
            //Debug.Log(jo);

            //parse root node (scene)
            string sBackground = string.Empty;
            string sImage      = string.Empty;
            string sMusic      = string.Empty;
            string sNext       = string.Empty;
            string sText       = string.Empty;

            if (jo["background"] != null)
            {
                sBackground = jo["background"].Value <string>();
            }
            if (jo["image"] != null)
            {
                sImage = jo["image"].Value <string>();
            }
            if (jo["music"] != null)
            {
                sMusic = jo["music"].Value <string>();
            }
            if (jo["default"] != null)
            {
                sNext = jo["default"].Value <string>();
            }
            if (jo["text"] != null)
            {
                sText = jo["text"].Value <string>();
            }
            Frame baseFrame = new Frame(sBackground, sImage, sNext, sMusic, string.Empty, sText, null, null);

            //parse frames
            Dictionary <string, Frame> frames = new Dictionary <string, Frame>();
            JObject jf = (JObject)jo["frames"];

            foreach (var x in jf)
            {
                try
                {
                    string key   = x.Key;
                    JToken value = x.Value;
                    Frame  f     = DialogueParser.ParseSingleFrame(value, baseFrame);
                    frames.Add(key, f);
                }
                catch (Exception e)
                {
                    Debug.Log("Failed to parse frame!");
                    Debug.Log(e);
                }
            }

            return(frames);
        }
Пример #2
0
 private void LoadScene(string scene)
 {
     CurrentSceneFrames = DialogueParser.LoadDialogue(scene);
     CurrentSceneName   = scene;
 }