2020-05-09 13:31:21 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using ResUpdate;
|
2021-06-16 10:44:12 +08:00
|
|
|
|
using UnityEngine.Networking;
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
namespace GameLogic
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 热更新面板
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UpdatePanel : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提示文字
|
|
|
|
|
/// </summary>
|
|
|
|
|
[SerializeField]
|
|
|
|
|
Text tipsText;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 进度条
|
|
|
|
|
/// </summary>
|
|
|
|
|
[SerializeField]
|
|
|
|
|
SliderCtrl slider;
|
|
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
|
UpdateMsgBox msgBox;
|
|
|
|
|
|
2021-05-31 21:36:05 +08:00
|
|
|
|
AssetBundle bundle;
|
2021-10-27 16:22:24 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
msgBox.gameObject.SetActive(false);
|
|
|
|
|
//StartCoroutine(GetGameConfig());
|
2021-10-21 10:21:03 +08:00
|
|
|
|
//BeginUpdatePlatform();
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-16 17:29:17 +08:00
|
|
|
|
public IEnumerator LoadFromStream(Action<Sprite> act)
|
2021-05-31 19:19:57 +08:00
|
|
|
|
{
|
2021-07-15 23:09:33 +08:00
|
|
|
|
|
|
|
|
|
string filePath = Application.streamingAssetsPath + "/Res/PackConfig.txt";
|
|
|
|
|
#if UNITY_IOS
|
|
|
|
|
filePath = "file://" + filePath;
|
|
|
|
|
#endif
|
|
|
|
|
XDebug.Log.l(filePath);
|
|
|
|
|
UnityWebRequest uwr = UnityWebRequest.Get(filePath);
|
2021-06-16 17:29:17 +08:00
|
|
|
|
yield return uwr.SendWebRequest();
|
|
|
|
|
if (uwr.isNetworkError || uwr.isHttpError)
|
2021-06-11 08:58:15 +08:00
|
|
|
|
{
|
2021-07-09 11:56:53 +08:00
|
|
|
|
XDebug.Log.l(uwr.error);
|
2021-06-16 10:44:12 +08:00
|
|
|
|
if (act != null)
|
|
|
|
|
{
|
|
|
|
|
act(null);
|
|
|
|
|
}
|
2021-06-11 08:58:15 +08:00
|
|
|
|
}
|
2021-06-16 10:44:12 +08:00
|
|
|
|
else
|
2021-05-31 19:19:57 +08:00
|
|
|
|
{
|
2021-06-16 17:29:17 +08:00
|
|
|
|
Hashtable table = MiniJSON.jsonDecode(uwr.downloadHandler.text) as Hashtable;
|
2021-10-21 10:21:03 +08:00
|
|
|
|
// 背景图
|
2021-06-16 17:29:17 +08:00
|
|
|
|
string bgName = table["UpdatePanelBG"] as string;
|
2021-07-15 23:09:33 +08:00
|
|
|
|
string texPath = Application.streamingAssetsPath + "/Res/" + bgName + ".png";
|
|
|
|
|
#if UNITY_IOS
|
|
|
|
|
texPath = "file://" + texPath;
|
|
|
|
|
#endif
|
|
|
|
|
UnityWebRequest www = UnityWebRequestTexture.GetTexture(texPath);
|
2021-06-16 17:29:17 +08:00
|
|
|
|
yield return www.SendWebRequest();
|
|
|
|
|
if (www.isNetworkError || www.isHttpError)
|
2021-05-31 21:36:05 +08:00
|
|
|
|
{
|
2021-07-09 11:56:53 +08:00
|
|
|
|
XDebug.Log.l(www.error);
|
2021-06-16 17:29:17 +08:00
|
|
|
|
if (act != null)
|
|
|
|
|
{
|
|
|
|
|
act(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-07-09 11:56:53 +08:00
|
|
|
|
XDebug.Log.l("load success");
|
2021-06-16 17:29:17 +08:00
|
|
|
|
Texture2D tex = ((DownloadHandlerTexture)www.downloadHandler).texture;
|
|
|
|
|
Sprite sp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0));
|
|
|
|
|
if (act != null)
|
|
|
|
|
{
|
|
|
|
|
act(sp);
|
|
|
|
|
}
|
2021-06-11 02:36:08 +08:00
|
|
|
|
}
|
2021-06-16 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
2021-06-30 19:50:47 +08:00
|
|
|
|
GameObject go = this.transform.Find("Canvas/LoadingScreen").gameObject;
|
2021-06-16 18:23:30 +08:00
|
|
|
|
go.SetActive(false);
|
2021-06-30 19:50:47 +08:00
|
|
|
|
GameObject go2 = this.transform.Find("Canvas/HighLayer").gameObject;
|
|
|
|
|
go2.SetActive(false);
|
2021-06-16 17:29:17 +08:00
|
|
|
|
Image img = this.transform.Find("Canvas/LoadingScreen/bg1").GetComponent<Image>();
|
|
|
|
|
img.color = new Color(1f, 1f, 1f, 0f);
|
|
|
|
|
StartCoroutine(LoadFromStream((Sprite sp) =>
|
2021-06-16 10:44:12 +08:00
|
|
|
|
{
|
2021-06-16 17:29:17 +08:00
|
|
|
|
if (sp != null)
|
2021-06-11 02:36:08 +08:00
|
|
|
|
{
|
2021-06-16 17:29:17 +08:00
|
|
|
|
img.sprite = sp;
|
|
|
|
|
}
|
|
|
|
|
img.color = new Color(1f, 1f, 1f, 1f);
|
2021-06-16 18:23:30 +08:00
|
|
|
|
go.SetActive(true);
|
2021-06-30 19:50:47 +08:00
|
|
|
|
go2.SetActive(true);
|
2021-10-21 10:21:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用户隐私协议
|
|
|
|
|
TryGetUserAgree(() =>
|
|
|
|
|
{
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-16 17:29:17 +08:00
|
|
|
|
}));
|
2021-10-21 10:21:03 +08:00
|
|
|
|
|
2021-05-31 19:19:57 +08:00
|
|
|
|
}
|
2021-10-21 10:21:03 +08:00
|
|
|
|
|
|
|
|
|
private void TryGetUserAgree(Action a)
|
2021-05-31 19:19:57 +08:00
|
|
|
|
{
|
2021-10-21 10:21:03 +08:00
|
|
|
|
// 判断是否需要显示用户隐私界面
|
2021-10-27 16:22:24 +08:00
|
|
|
|
Boolean needUserAgree = ConfigManager.Instance.IsSettingActive("APP_START_USER_AGREE");
|
2021-10-25 13:53:44 +08:00
|
|
|
|
if (!needUserAgree)
|
2021-05-31 19:19:57 +08:00
|
|
|
|
{
|
2021-10-21 10:21:03 +08:00
|
|
|
|
if (a != null)
|
|
|
|
|
{
|
|
|
|
|
a();
|
|
|
|
|
}
|
|
|
|
|
return;
|
2021-05-31 19:19:57 +08:00
|
|
|
|
}
|
2021-10-21 10:21:03 +08:00
|
|
|
|
// 判断是否已经同意
|
|
|
|
|
bool isAgree = PlayerPrefs.GetInt("APP_IsAgreeUser", 0) == 1;
|
|
|
|
|
if (isAgree)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
2021-10-21 10:21:03 +08:00
|
|
|
|
if (a != null)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
2021-10-21 10:21:03 +08:00
|
|
|
|
a();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 没同意则弹窗提示
|
2021-10-27 17:03:47 +08:00
|
|
|
|
string proto = "在您使用我们(猕猴桃)的服务前,请您务必审慎阅读、" +
|
|
|
|
|
"充分理解<color=#00A7FF>猕猴桃用户协议</color>和<color=#00A7FF>猕猴桃隐私政策</color>的各条款。" +
|
|
|
|
|
"<color=#FFFAD4><b>同时,您应特别注意前述协议中免除或者限制我们责任的条款、对您权利进行限制的、约定争议解决方式和司法管辖的条款。" +
|
|
|
|
|
"</b></color>如您已经详细阅读并同意<color=#00A7FF>猕猴桃用户协议</color>和<color=#00A7FF>猕猴桃隐私政策</color>," +
|
|
|
|
|
"请点击“同意”开始使用我们的服务。";
|
|
|
|
|
msgBox.ShowProto("不同意", "同意", proto, (r1) =>
|
2021-10-21 10:21:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (r1 == 1)
|
|
|
|
|
{
|
2021-10-27 17:03:47 +08:00
|
|
|
|
string grant = "为确保您的游戏体验,我们将在您使用我们的服务过程中申请以下权限,届时您可以选择同意或者拒绝开启相关权限,若是拒绝则会影响部分功能:" +
|
|
|
|
|
"\n\n" +
|
|
|
|
|
"<b> 储存权限 </b>" +
|
|
|
|
|
"我们访问您的储存权限是为了向您提供游戏截图保存功能" +
|
|
|
|
|
"\n\n" +
|
|
|
|
|
"<b> 电话权限 </b>" +
|
|
|
|
|
"我们访问您的电话权限是为了分析游戏的运行状态,优化游戏体验";
|
|
|
|
|
|
|
|
|
|
msgBox.ShowGrant("确定", grant,(result) =>
|
2021-10-21 10:21:03 +08:00
|
|
|
|
{
|
2021-10-25 13:53:44 +08:00
|
|
|
|
PlayerPrefs.SetInt("APP_IsAgreeUser", 1);
|
|
|
|
|
if (a != null)
|
|
|
|
|
{
|
|
|
|
|
a();
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-08-03 15:47:02 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-10-25 13:53:44 +08:00
|
|
|
|
msgBox.Show("退出游戏", "查看协议", "需要同意本隐私权政策才能继续游戏,若仍不同意本隐私权政策,很遗憾我们将无法为您提供服务。", (r2) =>
|
2021-08-03 15:47:02 +08:00
|
|
|
|
{
|
2021-10-21 10:21:03 +08:00
|
|
|
|
if (r2 == 1)
|
|
|
|
|
{
|
|
|
|
|
TryGetUserAgree(a);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-08-03 15:47:02 +08:00
|
|
|
|
Application.Quit();
|
2021-10-21 10:21:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-03 15:47:02 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2021-10-21 10:21:03 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
string updatePanelBg = ConfigManager.Instance.GetConfigInfo("Setting.UPDATE_PANEL_BG.value");
|
|
|
|
|
if (updatePanelBg != null)
|
|
|
|
|
{
|
|
|
|
|
if (bundle != null) bundle.Unload(true);
|
|
|
|
|
bundle = null;
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 10:21:03 +08:00
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
//if (Input.GetKeyDown(KeyCode.Escape))
|
|
|
|
|
//{
|
|
|
|
|
// if(AppConst.isSDK && App.SDKMgr.IsSupportExit())
|
|
|
|
|
// {
|
|
|
|
|
// App.SDKMgr.ExitGame();
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CANEL), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CONFIRM), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CONFIRM_CLOSE), (result) =>
|
|
|
|
|
// {
|
|
|
|
|
// if (result == 1)
|
|
|
|
|
// Application.Quit();
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
// void Start()
|
|
|
|
|
// {
|
|
|
|
|
//#if UNITY_EDITOR
|
|
|
|
|
//#elif UNITY_ANDROID
|
|
|
|
|
// Debug.LogError("UpdatePanel HideSplash Init SDKManager::::");
|
|
|
|
|
// using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
|
|
|
|
// {
|
|
|
|
|
// using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))
|
|
|
|
|
// {
|
|
|
|
|
// jo.Call("HideSplash");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//#elif UNITY_IPHONE || UNITY_IOS
|
|
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
IEnumerator GetGameConfig()
|
|
|
|
|
{
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_GAME_SETTINGS);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
var jsonData = UpdateManager.Instance.PostServerInfo();
|
|
|
|
|
WWW www = new WWW(AppConst.Download_apk_Url, Encoding.UTF8.GetBytes(jsonData));
|
|
|
|
|
yield return www;
|
|
|
|
|
if (string.IsNullOrEmpty(www.error))
|
|
|
|
|
{
|
|
|
|
|
OnGetGameConfig(www.text);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError(www.url+" "+www.error);
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_GAME_SETTINGS_FAILED), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
StartCoroutine(GetGameConfig());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
www.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CheckAndConvert<T>(Hashtable tab,string parameterName,object targetValue)
|
|
|
|
|
{
|
|
|
|
|
if(tab.Contains(parameterName))
|
|
|
|
|
{
|
|
|
|
|
var parStr= tab[parameterName] as string;
|
|
|
|
|
if(typeof(T) ==typeof(int))
|
|
|
|
|
{
|
|
|
|
|
int intValue=0;
|
|
|
|
|
if (int.TryParse(parStr, out intValue))
|
|
|
|
|
{
|
|
|
|
|
targetValue= intValue;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(typeof(T) ==typeof(bool))
|
|
|
|
|
{
|
|
|
|
|
if (parStr.ToLower() == "true" || parStr=="1")
|
|
|
|
|
{
|
|
|
|
|
targetValue = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (typeof(T) == typeof(string))
|
|
|
|
|
{
|
|
|
|
|
if (parStr!=null)
|
|
|
|
|
{
|
|
|
|
|
targetValue = parStr;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnGetGameConfig(string config)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(config))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Util.LogError("gameConfig::"+config);
|
|
|
|
|
var data = MiniJSON.jsonDecode(config) as Hashtable;
|
|
|
|
|
if(data==null || data.Contains("error"))
|
|
|
|
|
{
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_GAME_SETTINGS_ERROR), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
StartCoroutine(GetGameConfig());
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (AppConst.isUpdate)
|
|
|
|
|
{
|
|
|
|
|
BeginUpdateGame();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OnUpdateFinish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新游戏
|
|
|
|
|
/// </summary>
|
|
|
|
|
void BeginUpdateGame()
|
|
|
|
|
{
|
|
|
|
|
GameUpdateManager.Instance.BeginUpdate(OnGameUpdateStateChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新平台
|
|
|
|
|
/// </summary>
|
|
|
|
|
void BeginUpdatePlatform()
|
|
|
|
|
{
|
|
|
|
|
UpdateManager.Instance.UpdateResources(OnResourcesUpdateStateChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 游戏状态改变
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="isFinish"></param>
|
|
|
|
|
/// <param name="state"></param>
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
void OnGameUpdateStateChanged(bool isFinish, GameUpdateState state, object param)
|
|
|
|
|
{
|
|
|
|
|
//Debug.LogFormat("OnGameUpdateStateChanged=======>IsFinish:{0},State:{1}", isFinish, state.ToString());
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case GameUpdateState.DownLoadGameConfigs:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_VERSION_INFO);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.DownLoadGameConfigsFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_GAME_SETTINGS_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
BeginUpdateGame();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.NeedUpdateApp:
|
|
|
|
|
// msgBox.Show();
|
|
|
|
|
GameUpdateManager.Instance.UpdateApp();
|
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.DownLoadAPKProgress:
|
|
|
|
|
OnGameUpdateProgress(param as DownLoadProgress);
|
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.DownLoadAPKFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNlOAD_FILE_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
GameUpdateManager.Instance.UpdateAPK(true);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.Success:
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 资源更新状态改变
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="isFinish"></param>
|
|
|
|
|
/// <param name="state"></param>
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
void OnResourcesUpdateStateChanged(bool isFinish, ResourcesUpdateState state, object param)
|
|
|
|
|
{
|
|
|
|
|
//Debug.LogFormat("OnResourcesUpdateStateChanged=======>IsFinish:{0},State:{1}", isFinish, state.ToString());
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ResourcesUpdateState.GetGameConfigs:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_RESOURCES_SETTINGS);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.GetGameConfigsFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_RESOURCES_VERSION_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.DownLoadVersionFiles:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CHECK_RESOURCES_FILE);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.DownLoadVersionFilesFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_RESOURCES_SETTINGS_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.DownLoadFromNoWifi:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
slider.SetValue(0f);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
float size = 1f * (long)(param as object[])[0] / 1024 / 1024;
|
|
|
|
|
Action startDownAction = (param as object[])[1] as Action;
|
2021-01-26 17:08:39 +08:00
|
|
|
|
string msg = string.Format(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.NOT_WIFI_CONFIRM), size);
|
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CONFIRM), msg, (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
startDownAction();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.DownLoadWithWifi:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
slider.SetValue(0f);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
float size2 = 1f * (long)(param as object[])[0] / 1024 / 1024;
|
|
|
|
|
Action startDownAction2 = (param as object[])[1] as Action;
|
2021-01-26 17:08:39 +08:00
|
|
|
|
string msg2 = string.Format(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.WIFI_CONFIRM), size2);
|
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CONFIRM), msg2, (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
startDownAction2();
|
2020-08-22 15:31:14 +08:00
|
|
|
|
// 打点 - 开始更新
|
|
|
|
|
SDK.SdkCustomEvent.CustomEvent("Load-updates");
|
2020-05-09 13:31:21 +08:00
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.UpdateResourcesProgress:
|
|
|
|
|
OnResUpdateProgress(param as ResUpdateProgress);
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.UpdateResourcesFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNlOAD_RESOURCES_FILE_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.Success:
|
|
|
|
|
string version = (string)param;
|
|
|
|
|
VersionManager.Instance.SaveVersion(version);
|
|
|
|
|
OnUpdateFinish();
|
2020-08-22 15:31:14 +08:00
|
|
|
|
// 打点 - 更新完成
|
|
|
|
|
SDK.SdkCustomEvent.CustomEvent("End-loading");
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.OldPackageNeedChange:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNLOAD_NEWEST_APP));
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 游戏更新进度
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="progress"></param>
|
|
|
|
|
void OnGameUpdateProgress(DownLoadProgress progress)
|
|
|
|
|
{
|
|
|
|
|
slider.UpdateValue(progress.Progress);
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = string.Format(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNLOAD_PROGRESS_RATE), progress.SizeMB.ToString("f2"), progress.TotalSizeMB.ToString("f2"),progress.LoadSpeed.ToString("f2"));
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 资源更新进度
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="progress"></param>
|
|
|
|
|
void OnResUpdateProgress(ResUpdateProgress progress)
|
|
|
|
|
{
|
|
|
|
|
slider.UpdateValue(progress.Progress);
|
2021-03-07 20:48:05 +08:00
|
|
|
|
tipsText.text = string.Format(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNLOAD_PROGRESS), progress.SizeMB.ToString("f2"), progress.TotalSizeMB.ToString("f2"), (progress.SizeMB/progress.TotalSizeMB)*100);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新结束
|
|
|
|
|
/// </summary>
|
|
|
|
|
void OnUpdateFinish() {
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.UPDATE_COMPLETE);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
slider.SetValue(1f);
|
|
|
|
|
StartCoroutine(LoadGlobalRes());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator LoadGlobalRes() {
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RELOAD_RESOURCES);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
slider.SetValue(0f);
|
|
|
|
|
GlobalResLoader loader = new GlobalResLoader();
|
|
|
|
|
loader.LoadGlobalRes(null);
|
|
|
|
|
while (!loader.IsLoadFinish) {
|
|
|
|
|
slider.UpdateValue(loader.Progress);
|
|
|
|
|
yield return 1;
|
|
|
|
|
}
|
|
|
|
|
slider.SetValue(1f);
|
|
|
|
|
yield return new WaitForSeconds(0.1f);
|
|
|
|
|
yield return UpdateFinish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator UpdateFinish() {
|
|
|
|
|
yield return new WaitForSeconds(0.2f);
|
2021-06-16 10:44:12 +08:00
|
|
|
|
App.Instance.StartUp();
|
|
|
|
|
yield return new WaitForSeconds(1f);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
DestroyImmediate(this.gameObject);
|
|
|
|
|
UpdateManager.Instance.UnLoadUpdateAsset();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|