| System/ClientVersion/VersionUpdateWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/ClientVersion/VersionUtility.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Login/LoginModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Login/LoginWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
System/ClientVersion/VersionUpdateWin.cs
@@ -16,7 +16,9 @@ public class VersionUpdateWin : Window { [SerializeField] RectTransform m_ContainerHint; [SerializeField] RichText m_Content; [SerializeField] RichText m_HintDescription; [SerializeField] RectTransform m_UpdateContentContainer; [SerializeField] RichText m_UpdateCotent; [SerializeField] Button m_Confirm; [SerializeField] Transform m_ContainerProgress; @@ -108,14 +110,13 @@ private void DisplayHintContent() { var step = VersionUtility.Instance.step; switch (step) { case VersionUtility.Step.None: m_Content.text = Language.GetFromLocal(4); m_HintDescription.text = Language.GetFromLocal(4); break; case VersionUtility.Step.ApkExist: m_Content.text = Language.GetFromLocal(5); m_HintDescription.text = Language.GetFromLocal(5); break; case VersionUtility.Step.DownLoadPrepared: if (Application.platform == RuntimePlatform.Android) @@ -125,28 +126,49 @@ switch (Application.internetReachability) { case NetworkReachability.NotReachable: m_Content.text = Language.GetFromLocal(6, sizeDescription); m_HintDescription.text = Language.GetFromLocal(6, sizeDescription); break; case NetworkReachability.ReachableViaCarrierDataNetwork: m_Content.text = Language.GetFromLocal(7, sizeDescription); m_HintDescription.text = Language.GetFromLocal(7, sizeDescription); break; case NetworkReachability.ReachableViaLocalAreaNetwork: m_Content.text = Language.GetFromLocal(8, sizeDescription); m_HintDescription.text = Language.GetFromLocal(8, sizeDescription); break; } } else if (Application.platform == RuntimePlatform.IPhonePlayer) { m_Content.text = Language.GetFromLocal(9); m_HintDescription.text = Language.GetFromLocal(9); } break; case VersionUtility.Step.DownLoad: m_Content.text = Language.GetFromLocal(3); m_HintDescription.text = Language.GetFromLocal(3); break; case VersionUtility.Step.DownLoadFailed: m_Content.text = Language.GetFromLocal(10); m_HintDescription.text = Language.GetFromLocal(10); break; } switch (step) { case VersionUtility.Step.ApkExist: case VersionUtility.Step.DownLoadPrepared: var updateContent = VersionUtility.Instance.GetUpdateContent(); if (string.IsNullOrEmpty(updateContent)) { m_UpdateContentContainer.gameObject.SetActive(false); } else { m_UpdateContentContainer.gameObject.SetActive(true); m_UpdateCotent.text = updateContent; } break; default: m_UpdateContentContainer.gameObject.SetActive(false); break; } } private void Confirm() @@ -160,11 +182,7 @@ VersionUtility.Instance.RequestVersionCheck(); break; case VersionUtility.Step.ApkExist: var version = VersionUtility.Instance.versionInfo.GetLatestVersion(); var remoteURL = version.download_url; var fileName = Path.GetFileName(remoteURL); var apkLocalURL = StringUtility.Contact(VersionUtility.Instance.androidRoot, "/", fileName); SDKUtility.Instance.InstallAPK(apkLocalURL); SDKUtility.Instance.InstallAPK(VersionUtility.Instance.GetApkLocalUrl()); break; case VersionUtility.Step.DownLoadPrepared: if (Application.platform == RuntimePlatform.Android) @@ -173,7 +191,7 @@ } else if (Application.platform == RuntimePlatform.IPhonePlayer) { Application.OpenURL(VersionUtility.Instance.versionInfo.GetLatestVersion().download_url); Application.OpenURL(VersionUtility.Instance.GetApkRemoteUrl()); //打开应用商店链接 } break; System/ClientVersion/VersionUtility.cs
@@ -20,21 +20,18 @@ public string androidRoot { get { return StringUtility.Contact(SDKUtility.Instance.DeviceRootPath, "/", VersionConfig.Get().bundleIdentifier); } } public float progress { public float progress { get { return RemoteFile.TotalDownloadedSize / ((float)versionInfo.GetLatestVersion().file_size * 1024); } } public string apkLocalURL = string.Empty; public VersionInfo versionInfo { get; private set; } public MaoErVersion maoerVersion; public bool completed { get { return step == Step.Completed; } } Step m_Step = Step.None; public Step step { public Step step { get { return m_Step; } private set { private set { if (m_Step != value) { m_Step = value; @@ -70,17 +67,12 @@ if (_ok) { versionInfo = JsonMapper.ToObject<VersionInfo>(_result); if (versionInfo.VersionCount > 0) if (NeedUpdate()) { var version = versionInfo.GetLatestVersion(); var remoteURL = version.download_url; switch (Application.platform) { case RuntimePlatform.Android: var fileName = Path.GetFileName(remoteURL); apkLocalURL = StringUtility.Contact(androidRoot, "/", fileName); if (File.Exists(apkLocalURL)) if (File.Exists(GetApkLocalUrl())) { step = Step.ApkExist; WindowCenter.Instance.OpenFromLocal<VersionUpdateWin>(); @@ -118,18 +110,74 @@ } } public bool NeedUpdate() { if (IsMaoErGame()) { return versionInfo.downAsset == 0 && versionInfo.VersionCount > 0; } else { return versionInfo.downAsset == 1 && versionInfo.VersionCount > 0; } } public string GetApkLocalUrl() { if (IsMaoErGame()) { return StringUtility.Contact(androidRoot, "/", "maoErGame.apk"); } else { var remoteURL = GetApkRemoteUrl(); var fileName = Path.GetFileName(remoteURL); return StringUtility.Contact(androidRoot, "/", fileName); } } public string GetApkRemoteUrl() { if (IsMaoErGame()) { return maoerVersion.url; } else { var version = versionInfo.GetLatestVersion(); return version.download_url; } } public string GetUpdateContent() { if (IsMaoErGame()) { if (string.IsNullOrEmpty(maoerVersion.content)) { return string.Empty; } else { return StringUtility.Contact(Language.GetFromLocal(30), "\r\n", maoerVersion.content); } } else { return string.Empty; } } public void StartDownLoad() { step = Step.DownLoad; var version = versionInfo.GetLatestVersion(); var remoteURL = version.download_url; var fileName = Path.GetFileName(remoteURL); apkLocalURL = StringUtility.Contact(androidRoot, "/", fileName); var remoteURL = GetApkRemoteUrl(); var apkLocalUrl = GetApkLocalUrl(); RemoteFile.Prepare(); var remoteFile = new RemoteFile(); remoteFile.Init(remoteURL, apkLocalURL, null); remoteFile.Init(remoteURL, apkLocalUrl, null); remoteFile.Begin(OnDownLoadApkCompleted); } @@ -155,7 +203,7 @@ } } SDKUtility.Instance.InstallAPK(apkLocalURL); SDKUtility.Instance.InstallAPK(GetApkLocalUrl()); } else { @@ -168,10 +216,54 @@ step = Step.Completed; } const string maoerGameAppId = "mrgame"; static List<string> maoerGameAppId = new List<string> { "mrgame", "mrgameios" }; public bool IsMaoErGame() { return VersionConfig.Get().appId == maoerGameAppId; return maoerGameAppId.Contains(VersionConfig.Get().appId); } public void RequestMaoErVersionCheck() { if (IsMaoErGame() && versionInfo.VersionCount > 0) { step = Step.None; var tables = new Dictionary<string, string>(); tables["uid"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account; var url = "https://api.maoergame.com/update/download/url"; HttpRequest.Instance.RequestHttpPost(url, tables, HttpRequest.defaultHttpContentType, 1, OnMaoErVersionCheckResult); } } private void OnMaoErVersionCheckResult(bool ok, string result) { if (ok) { try { maoerVersion = JsonMapper.ToObject<MaoErVersion>(result); if (maoerVersion.code == 0) { step = Step.DownLoadPrepared; WindowCenter.Instance.OpenFromLocal<VersionUpdateWin>(); } else { step = Step.None; Clock.Create(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), RequestMaoErVersionCheck); } } catch (System.Exception ex) { step = Step.None; Clock.Create(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), RequestMaoErVersionCheck); } } else { step = Step.None; Clock.Create(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), RequestMaoErVersionCheck); } } public class VersionInfo @@ -181,7 +273,7 @@ public JsonData resource_url; public JsonData notice_flag; public Version[] versions; public int downAsset =1; public int downAsset = 1; public Version GetLatestVersion() { @@ -240,6 +332,14 @@ public string version_name; } public struct MaoErVersion { public string msg; public int code; public string content; public string url; } public enum Step { None, System/Login/LoginModel.cs
@@ -15,8 +15,7 @@ public SDKUtility.FP_LoginOk sdkLoginResult; public SDKUtility.FP_CheckIDAuthentication sdkIDCheckIDAuthentication; public string localSaveAccountName { public string localSaveAccountName { get { return LocalSave.GetString(USER_ACCOUNT); } set { LocalSave.SetString(USER_ACCOUNT, value); } } @@ -25,22 +24,19 @@ public event Action accountBindOkEvent; bool m_ReconnecBackGround = false; public bool reconnectBackGround { public bool reconnectBackGround { get { return m_ReconnecBackGround; } set { m_ReconnecBackGround = value; } } bool m_OnCreateRole = false; public bool onCreateRole { public bool onCreateRole { get { return m_OnCreateRole; } set { m_OnCreateRole = value; } } bool m_Busy = false; public bool busy { public bool busy { get { return m_Busy; } set { m_Busy = value; } } @@ -90,11 +86,18 @@ } SDKUtility.Instance.FreePlatformCheckIDAuthentication(sdkLoginResult.account); ServerListCenter.Instance.RequestServerListPlayer(sdkLoginResult.account); GameNotice.OpenGameNotice(); SDKUtility.Instance.MakeKeyAndVisible(); OperationLogCollect.Instance.RecordLauchEvent(5); if (VersionUtility.Instance.IsMaoErGame() && VersionUtility.Instance.NeedUpdate()) { VersionUtility.Instance.RequestMaoErVersionCheck(); } else { GameNotice.OpenGameNotice(); } } private void OnSDKAccountLoginOutOk() System/Login/LoginWin.cs
@@ -169,6 +169,11 @@ return; } if (VersionUtility.Instance.step != VersionUtility.Step.Completed) { return; } Login(); }