예제 #1
0
        IEnumerator GetDownloadText(string url, DownloadText retText)
        {
            var www = UnityWebRequest.Get(url);

            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                OnUpdateFailed(www.error);
                yield break;
            }
            retText.text = www.downloadHandler.text;
        }
예제 #2
0
    public static IEnumerator LoadData()
    {
        if (RawJSON != null)
        {
            yield break;
        }

        var download = new DownloadText("https://ktane.timwi.de/json/raw");

        yield return(download);

        RawJSON = download.Text;
        Modules = JsonConvert.DeserializeObject <WebsiteJSON>(RawJSON).KtaneModules;
    }
예제 #3
0
 public GoogleSheet(string sheetID, string gid = "0", params string[] columns)
 {
     download    = new DownloadText($"https://docs.google.com/spreadsheets/d/{sheetID}/gviz/tq?tqx=out:json&gid={gid}");
     columnNames = columns;
 }
예제 #4
0
        public IEnumerator OnResUpdate(Action updateOK)
        {
            if (!AppConst.UpdateMode)
            {
                updateOK.Invoke();
                yield break;
            }
            var verfile      = Util.DataPath + "version.txt";
            var localVerInfo = Util.GetVersionInfo(verfile);

            if (localVerInfo == null)
            {
                OnUpdateFailed("localVerInfo was null!!!");
                yield break;
            }
            long localPatchVer = long.Parse(localVerInfo.patchVersion); //本地版本号

            ///获取版本列表文件内容
            string versionUrl = AppConst.ResUrl + "version.txt?v=" + Util.RandomTime();

            Debug.LogWarning("LoadVersionUrl---->>>" + versionUrl);

            var versionText = new DownloadText();

            yield return(StartCoroutine(GetDownloadText(versionUrl, versionText)));

            var remoteVerInfo = Util.InitVersionInfo(versionText.text);

            if (remoteVerInfo == null)
            {
                OnUpdateFailed("remoteVerInfo was null!!!");
                yield break;
            }

            ///比较版本,是否需要整包更新
            var localMainVer     = int.Parse(localVerInfo.mainVersion);
            var remoteMainVer    = int.Parse(remoteVerInfo.mainVersion);
            var localPrimaryVer  = int.Parse(localVerInfo.primaryVersion);
            var remotePrimaryVer = int.Parse(remoteVerInfo.primaryVersion);

            if (localMainVer < remoteMainVer || localPrimaryVer < remotePrimaryVer)
            {
                Debug.LogError("版本太老,需要整包资源更新,才可以继续游戏。。");
                yield break;
            }

            //获取补丁列表文件内容
            var    patchsFile = "patchs_" + remoteVerInfo.mainVersion + "_" + remoteVerInfo.primaryVersion + ".txt";
            string patchsUrl  = AppConst.PatchUrl + patchsFile + "?v=" + Util.RandomTime();

            Debug.LogWarning("LoadPatchsUrl---->>>" + patchsUrl);

            var patchsText = new DownloadText();

            yield return(StartCoroutine(GetDownloadText(patchsUrl, patchsText)));

            var lines = patchsText.text.Split('\n');

            var zipFiles    = new List <string>();
            var loadingText = "正在更新资源,请稍等...";

            Util.UpdateLoadingProgress(loadingText, 0, lines.Length);
            for (int i = 0; i < lines.Length; i++)
            {
                var line = lines[i].Trim();
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                var strs = line.Split('|');
                var file = Path.GetFileNameWithoutExtension(strs[0]);

                var remoteStrs = file.Split('_');
                var remoteVer  = long.Parse(remoteStrs[1].Trim());  //远程版本号

                if (remoteVer <= localPatchVer)
                {
                    continue;
                }

                zipFiles.Add(file + ".zip");
                var outfile = Util.DataPath + file + ".zip";

                yield return(StartCoroutine(DownloadFile(strs[0], outfile)));

                Util.UpdateLoadingProgress(loadingText, i + 1, lines.Length);
            }
            var localVerFile = Util.DataPath + "version.txt";
            var remoteVerStr = zipFiles.Count > 0 ? versionText.text : string.Empty;

            ProcZipFiles(zipFiles, () => OnUpdateOK(localVerFile, remoteVerStr, updateOK));
        }
예제 #5
0
 public GoogleSheet(string url, params string[] rows)
 {
     download  = new DownloadText(url);
     this.rows = rows;
 }