| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | //-------------------------------------------------------- |
| | | // [Author]: 玩个游戏 |
| | | // [ Date ]: Thursday, March 15, 2018 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | |
| | | using LitJson; |
| | | using System.IO; |
| | | using System.Text; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | |
| | | public class VersionUtility : Singleton<VersionUtility> |
| | | { |
| | | public static readonly string[] VERSION_URL = new string[] { |
| | | "http://gamecenter.secondworld.net.cn:11000/center/appversion_new.php/?"}; |
| | | // public static readonly string[] VERSION_URL = new string[] { |
| | | // "http://gamecenter.secondworld.net.cn:11000/center/appversion_new.php/?"}; |
| | | |
| | | public string androidRoot { get { return string.Empty;/*StringUtility.Contact(SDKUtils.Instance.DeviceRootPath, "/", VersionConfig.Get().bundleIdentifier);*/ } } |
| | | public string androidRoot { get { return string.Empty;/*StringUtility.Concat(SDKUtils.Instance.DeviceRootPath, "/", VersionConfig.Get().bundleIdentifier);*/ } } |
| | | |
| | | public DownloadTask downloadTask; |
| | | public DownloadHotTask downloadTask; |
| | | private string versionUrl; |
| | | public float progress |
| | | { |
| | |
| | | |
| | | //tables["game"] = VersionConfig.Get().gameId; |
| | | |
| | | //var url = StringUtility.Contact(VERSION_URL[urlIndex % 2], HttpRequest.HashtablaToString(tables)); |
| | | //var url = StringUtility.Concat(VERSION_URL[urlIndex % 2], HttpRequest.HashtablaToString(tables)); |
| | | //urlIndex++; |
| | | //versionUrl = url; |
| | | //Debug.Log("http地址:versionUrl " + url); |
| | |
| | | { |
| | | step = Step.Completed; |
| | | |
| | | #if !UNITY_WEBGL |
| | | var apkFiles = new DirectoryInfo(ResourcesPath.Instance.ExternalStorePath).GetFiles("*.apk"); |
| | | for (int i = apkFiles.Length - 1; i >= 0; i--) |
| | | { |
| | | File.Delete(apkFiles[i].FullName); |
| | | } |
| | | #endif |
| | | } |
| | | } |
| | | else |
| | |
| | | public void RequestApkDownConfigs() |
| | | { |
| | | // YLTODO |
| | | // UIManager.Instance.OpenWindow<VersionUpdateWin>(); |
| | | // UIManager.Instance.OpenWindowAsync<VersionUpdateWin>().Forget(); |
| | | // // WindowCenter.Instance.OpenFromLocal<VersionUpdateWin>(); |
| | | } |
| | | |
| | |
| | | return string.Empty; |
| | | var remoteURL = GetApkRemoteUrl(); |
| | | var fileName = Path.GetFileName(remoteURL); |
| | | return StringUtility.Contact(androidRoot, "/", fileName); |
| | | return StringUtility.Concat(androidRoot, "/", fileName); |
| | | } |
| | | |
| | | public string GetApkRemoteUrl() |
| | |
| | | var remoteURL = GetApkRemoteUrl(); |
| | | var apkLocalUrl = GetApkLocalUrl(); |
| | | |
| | | downloadTask = new DownloadTask(remoteURL, apkLocalUrl); |
| | | downloadTask = new DownloadHotTask(remoteURL, apkLocalUrl); |
| | | downloadTask.BeginDownload(OnDownLoadApkCompleted); |
| | | } |
| | | |
| | | private void OnDownLoadApkCompleted(DownloadTask task) |
| | | private void OnDownLoadApkCompleted(DownloadHotTask task) |
| | | { |
| | | if (task.IsDone) |
| | | { |
| | |
| | | /// 是否为ios审核时间内 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public bool InIosAuditTime() |
| | | public async UniTask<bool> InIosAuditTime() |
| | | { |
| | | DateTime dateTime; |
| | | |
| | | try |
| | | { |
| | | var textAsset = Resources.Load<UnityEngine.TextAsset>("Config/AuditTime"); |
| | | var textAsset = await Resources.LoadAsync<UnityEngine.TextAsset>("Config/AuditTime") as UnityEngine.TextAsset; |
| | | var content = string.Empty; |
| | | if (textAsset != null) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | catch (System.Exception) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | |
| | | public bool NeedDownAsset() |
| | | { |
| | | if (versionInfo != null && versionInfo.downAsset == 1 && VersionConfig.Get().assetAccess != InstalledAsset.IngoreDownLoad) |
| | | if (VersionConfig.config == null) |
| | | { |
| | | VersionConfig.GetAsync().Forget(); |
| | | Debug.LogError("VersionConfig is null when check NeedDownAsset, check VersionConfig.GetAsync for more details"); |
| | | return false; |
| | | } |
| | | |
| | | if (versionInfo != null && versionInfo.downAsset == 1 && VersionConfig.config.assetAccess != InstalledAsset.IngoreDownLoad) |
| | | { |
| | | return true; |
| | | } |