public static Area Load(string mod) //Area { string LastTime = ""; string LastTimeNew = ""; string Source = SceneTools.GetSettingValue("Source"); if (Source == "") { Source = "realdata"; SceneTools.ChangeSetting("realdata", "34", "false"); } SceneTools.CurrentSource = SceneTools.GetSettingValue("Source"); Debug.Log(Source); bool isExistDateFile = File.Exists(SceneTools.AreaZipLastTimeLocal()); if (mod.Equals("download"))//update or download { if (Source == "realdata") { Debug.LogWarning("Downloading readdata"); if (!File.Exists(SceneTools.AreaZipFileLocal()))//not exist zip { SceneTools.ClearLocalData(); SceneTools.DownloadFileFromUrlSync(SceneTools.AreaZipLastTimeUrl(), SceneTools.AreaZipLastTimeLocal()); SceneTools.DownloadFileFromUrlSync(SceneTools.AreaZipFileUrl(), SceneTools.AreaZipFileLocal()); new ZipIt(SceneTools.AreaZipFileLocal(), "", Application.persistentDataPath); } //} else //the have zip,then check the update { if (isExistDateFile) { LastTime = File.ReadAllText(SceneTools.AreaZipLastTimeLocal()); SceneTools.DownloadFileFromUrlSync(SceneTools.AreaZipLastTimeUrl(), SceneTools.AreaZipLastTimeLocal()); LastTimeNew = File.ReadAllText(SceneTools.AreaZipLastTimeLocal()); if (Convert.ToInt64(LastTimeNew) > Convert.ToInt64(LastTime)) { //update Debug.Log("Downloading new zip file"); SceneTools.DownloadFileFromUrlSync(SceneTools.AreaZipFileUrl(), SceneTools.AreaZipFileLocal()); new ZipIt(SceneTools.AreaZipFileLocal(), "", Application.persistentDataPath); } else { //not gonna update Debug.Log("Zip file is latest version"); } } else //unknown version ,so update ,or last version is test { SceneTools.ClearLocalData(); Debug.Log("Zip not File.Exists (SceneTools.AreaZipLastTimeLocal())"); SceneTools.DownloadFileFromUrlSync(SceneTools.AreaZipLastTimeUrl(), SceneTools.AreaZipLastTimeLocal()); SceneTools.DownloadFileFromUrlSync(SceneTools.AreaZipFileUrl(), SceneTools.AreaZipFileLocal());//AreaZipFileUrl() new ZipIt(SceneTools.AreaZipFileLocal(), "", Application.persistentDataPath); } } } else if (Source == "Test") { if (isExistDateFile) { //realdata SceneTools.ClearLocalData(); //delete realdata SceneTools.DownloadFileFromUrlSync(SceneTools.testZip, SceneTools.AreaZipFileLocal()); new ZipIt(SceneTools.AreaZipFileLocal(), "", Application.persistentDataPath); } else if (!File.Exists(SceneTools.AreaZipFileLocal())) { SceneTools.ClearLocalData();//delete realdata SceneTools.DownloadFileFromUrlSync(SceneTools.testZip, SceneTools.AreaZipFileLocal()); new ZipIt(SceneTools.AreaZipFileLocal(), "", Application.persistentDataPath); } } //{ } SceneTools.ChangeSetting(SceneTools.CurrentSource, "34", "false"); //convert the xml into a cs object (after downloading all the file or file is already) var serializer = new XmlSerializer(typeof(Area)); using (var stream = new FileStream(Path.Combine(Application.persistentDataPath + "/" + SceneTools.AreaNameDefault(), SceneTools.AreaNameDefault() + ".xml"), FileMode.Open)) { return(serializer.Deserialize(stream) as Area); } }