Ejemplo n.º 1
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     DontDestroyOnLoad(gameObject);
     InitDictionary();
 }
 //Reload the resources on awake
 void Awake()
 {
     DialogOptions = Resources.Load <DialogDictionary>("DialogData");
 }
Ejemplo n.º 3
0
        public static void LoadHtmlDialogs(string root)
        {
            string serializedPath = Path.Combine(root, @".\dialogs\dialogs.dat");
            if (File.Exists(serializedPath)) {
                try {
                    using (FileStream fs = new FileStream(serializedPath, FileMode.Open)) {
                        BinaryFormatter bf = new BinaryFormatter();
                        DialogFiles = (DialogDictionary)bf.Deserialize(fs);
                    }
                } catch (Exception ex) {
                    Debug.Print(ex.ToString());
                }
            }

            if (DialogFiles == null) {
                DialogFiles = new DialogDictionary();
            } else {
                return;
            }

            List<string> files = new List<string>();
            files.AddRange(Directory.GetFiles(Path.Combine(root, @"dialogs"), @"*.html",
                                              SearchOption.AllDirectories));

            for (int i = 0; i < files.Count; i++) {
                string name = Path.GetFileName(files[i]);
                if (name.ToLower().StartsWith("quest_"))
                    continue;
                string qId = Path.GetFileNameWithoutExtension(Path.GetFileName(files[i])).Trim();
                DirectoryInfo info = new DirectoryInfo(files[i]);
                while (info.Parent.Name.ToLower() != "dialogs") {
                    qId += '|' + info.Parent.Name;
                    info = info.Parent;
                }
                if (!DialogFiles.ContainsKey(qId)) {
                    Dialogs dialogs;
                    if (TryLoadQuestHtml(files[i], out dialogs))
                        DialogFiles.Add(qId, dialogs);
                }
            }

            try {
                using (FileStream fs = new FileStream(serializedPath, FileMode.Create)) {
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(fs, DialogFiles);
                }
            } catch (Exception ex) {
                Debug.Print(ex.ToString());
            }
        }
Ejemplo n.º 4
0
        public static void LoadHtmlDialogs(string root)
        {
            string serializedPath = Path.Combine(root, @".\dialogs\dialogs.dat");

            if (File.Exists(serializedPath))
            {
                try {
                    using (FileStream fs = new FileStream(serializedPath, FileMode.Open)) {
                        BinaryFormatter bf = new BinaryFormatter();
                        DialogFiles = (DialogDictionary)bf.Deserialize(fs);
                    }
                } catch (Exception ex) {
                    Debug.Print(ex.ToString());
                }
            }

            if (DialogFiles == null)
            {
                DialogFiles = new DialogDictionary();
            }
            else
            {
                return;
            }

            List <string> files = new List <string>();

            files.AddRange(Directory.GetFiles(Path.Combine(root, @"dialogs"), @"*.html",
                                              SearchOption.AllDirectories));

            for (int i = 0; i < files.Count; i++)
            {
                string name = Path.GetFileName(files[i]);
                if (name.ToLower().StartsWith("quest_"))
                {
                    continue;
                }
                string        qId  = Path.GetFileNameWithoutExtension(Path.GetFileName(files[i])).Trim();
                DirectoryInfo info = new DirectoryInfo(files[i]);
                while (info.Parent.Name.ToLower() != "dialogs")
                {
                    qId += '|' + info.Parent.Name;
                    info = info.Parent;
                }
                if (!DialogFiles.ContainsKey(qId))
                {
                    Dialogs dialogs;
                    if (TryLoadQuestHtml(files[i], out dialogs))
                    {
                        DialogFiles.Add(qId, dialogs);
                    }
                }
            }

            try {
                using (FileStream fs = new FileStream(serializedPath, FileMode.Create)) {
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(fs, DialogFiles);
                }
            } catch (Exception ex) {
                Debug.Print(ex.ToString());
            }
        }
 //loads the language data to the language dictionary
 static DialogHelper()
 {
     DialogOptions = Resources.Load <DialogDictionary>("DialogData");
 }