changhong/wb_unity_pro/Assets/Scripts/VerCheck.cs

737 lines
46 KiB
C#
Raw Normal View History

using UnityEngine;
using System.Collections;
using System.IO;
using FairyGUI;
using MiniJSON;
using UnityEngine.Networking;
using taurus.unity;
using System.Text;
using System;
using taurus.client;
public class VerCheck : MonoBehaviour
{
GComponent _version_view;
public static VerCheck Instance { get; private set; }
public securityConnection conn;
public bool isGFF = false;
public bool isDXYGFF = true;
void Awake()
{
Instance = this;
}
// Use this for initialization
void Start()
{
GameApplication.Instance.isAndroid64bit = IsAndroid64bit();
CreateVersionView();
StartCoroutine(CheckNet());
}
internal void ResetGame()
{
CreateVersionView();
StartCoroutine(__WaitReset());
}
IEnumerator __WaitReset()
{
var _luaClient = GameApplication.Instance.GetComponent<DSLuaClient>();
UnityEngine.Object.Destroy(_luaClient);
System.GC.Collect();
FontManager.Clear();
UIPackage.RemoveAllPackages();
ResourcesManager.DestroyAll();
CreateVersionView();
yield return null;
StartCoroutine(CheckNet());
}
void CreateVersionView()
{
ResourcesManager.ReadAssetConfig("base/embed");
UIPackage.AddPackage("base/embed/ui/Hotupdate");
if (_version_view != null) _version_view.Dispose();
_version_view = null;
_version_view = UIPackage.CreateObjectFromURL("ui://Hotupdate/Version").asCom;
GRoot.inst.AddChildAt(_version_view,0);
_version_view.width = GRoot.inst.width;
_version_view.height = GRoot.inst.height;
_version_view.x = (GRoot.inst.width - _version_view.width) / 2;
Debug.LogError(Application.persistentDataPath);
}
public bool IsAndroid64bit()
{
#if UNITY_ANDROID && !UNITY_EDITOR
if (IntPtr.Size == 8)
{
return true;
}
return false;
#else
return false;
#endif
}
IEnumerator CheckNet()
{
string json_data = string.Empty;
2025-09-22 17:27:49 +08:00
isDXYGFF= false;
isGFF = false;
2025-09-22 17:27:49 +08:00
//公用
2025-09-12 23:06:53 +08:00
2025-11-08 20:02:29 +08:00
string init_url = "http://8.148.151.16:19898/NewFK/config/init2_1.json";
2025-09-22 17:27:49 +08:00
if (isGFF==false&&isDXYGFF==false)
{
}
else
{
if (isGFF)
{
int rc = AppVest.init("8ef91e7e799b5851a8ce810aae0c697c", "U5ayF4voVvRh1ElqBIVUCR9dSFskPGvCkfreFxdxzi39hoU0faqZWjFzC90Cta50egaQatCbPxm6XTlvi2+o++PrSozoZ+HUUY0y8tBloMWaOYQX59SAhjA/DyIDHJgGbE1I");
if (rc != 0)
{
// Debug.LogError("init failed");
ShowTip("GF init failed!", () =>
{
StartCoroutine(CheckNet());
});
}
// Debug.LogError("init successful");
conn.ip = "";
conn.port = 0;
int rc1 = AppVest.getServerIPAndPort(ref conn, "", 5021);
if (rc1 != 0)
{
ShowTip("getServerIPAndPort failed!", () =>
{
StartCoroutine(CheckNet());
});
yield break;
}
}
else
{
2025-11-08 20:02:29 +08:00
// string key = "yejrC7W28wGjORAAAFUw4C2/BDBkvh6yEbdXN0Ap2JSozUt3H1sh+IE4x4ZrwrB1hgeT+xJFrT99Sbn8X7y/eg15VpAJt8HRngquLPWXRk0H4LA5lduCYh8L+dShI5nDd0148GwgbM1FwF0HloFI5ANs9X0MhuQx9vJw/L3sMHpv6bOoHlTg5Xd3pQkaNq1JoTjJ1Ltkg2pBf/f9zgjAN9lE+CvXLoDEifBIeIcXMG5qBNbWqbJSgaDtH6wcLYIdLX0jVAJmRPcV1Aw2Ng8zr2R4+aQTEz1vsq3YZusGTHzUblRy2YewWD1b5zqpCivMF7dJhvU7NivZen01p1+eAlo3sWyUrkjD+QVInwjRSMgPdlkH33LO6HYENClhl4SbDyGfmvD6Qrab3s/4FlQuV3WpUq5CzZ0iccKxqDBa/BTtpFQiYh/VYmSWU9TQ3IBIEqPlXYx8xKhzmUMIvMgZfupSy9WQfDlDwb0YilD7qotLgELPWyPRMSv6z9tAOZ7hYouAnev4CAm5fz+p2/D4Yxw6NnksByNrB2DLXVrtxbreXWmzETw/xuffqY4H/EeUyQ5YLuIomAOqIukFkxrk+DAmUzsJOv9av1Zho8aallN0OhcpV1VevK1qTMj9cUnlo4Y5QDpmlY1mRmGKEVs/P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nF+x+wjB6cB1TEwIUviviQlofNvM4qJFLH55ON85n2pFBhSGW3qLF/");
if (rc != 150)
{
Debug.LogError("wwwwwwwwwwwwwwwwwwwwwww init failed");
ShowTip("GF init failed!", () =>
{
StartCoroutine(CheckNet());
});
}
// Debug.LogError("init successful");
conn.ip = "127.0.0.1";
2025-11-08 20:02:29 +08:00
conn.port = 18080;
//int rc1 = AppVest.getServerIPAndPort(ref conn, "", 8077);
//if (rc1 != 0)
//{
// ShowTip("getServerIPAndPort failed!", () =>
// {
// StartCoroutine(CheckNet());
// });
// yield break;
//}
}
2025-09-01 17:41:29 +08:00
init_url = "http://" + conn.ip + ":" + conn.port + "/NewFK/config/init2_1.json";
Debug.LogError("init_url : " + init_url);
}
// Debug.LogError("开始下载资源===>>>");
// Debug.LogError(init_url);
//Debug.LogError("init_url============================ "+ init_url);
float downTimeOut = 5;
using (WWW request1 = new WWW(init_url))
{
float timeOut = Time.time;
float process = request1.progress;
while (request1!=null && request1.isDone==false)
{
//Debug.LogError("wwwwwwwwwwwwwwwwwww11111111111111111111111");
if(process<request1.progress)
{
timeOut = Time.time;
process = request1.progress;
}
if(Time.time-timeOut>downTimeOut)
{
ShowTip("配置文件下载失败,请检查您的网络设置!", () =>
{
StartCoroutine(CheckNet());
});
yield break;
}
yield return null;
}
yield return request1;
// Debug.LogError("request1.error"+request1.error);
if (string.IsNullOrEmpty(request1.error))
{
//Debug.LogError("wwwwwwwwwwwwwwwww222222222222222222222222");
json_data = request1.text;
//优化
GameApplication.Instance.GameInfo = json_data;
Hashtable json = Json.Deserialize(json_data) as Hashtable;
//json["pack_url"] = "http://8.134.59.224:8909/NewFKtest";
Hotupdate.PackUrl = (string)json["pack_url"];
Hashtable _plat_data = null;
#if UNITY_IPHONE
_plat_data = json["iOS"] as Hashtable;
#endif
#if UNITY_ANDROID
_plat_data = json["Android"] as Hashtable;
#endif
#if UNITY_STANDALONE
_plat_data = json["Win"] as Hashtable;
#endif
var check = _plat_data[string.Format("check{0}", GameApplication.AppVersion.ToString())];
if (check != null && (bool)check)
{
GameApplication.HideSdk = true;
GameApplication.Instance.accountTest = false;
}
Version server_version = new Version((string)_plat_data["version"]);
if (!GameApplication.HideSdk)
{
if (GameApplication.AppVersion.max_version < server_version.max_version || (GameApplication.AppVersion.max_version == server_version.max_version && GameApplication.AppVersion.min_version < server_version.min_version))
{
ShowTip("您版本需要更新!", () =>
{
#if UNITY_ANDROID
StartCoroutine(DownApp((string)_plat_data["appurl"], server_version.ToString()));
#else
DeleteOldPack();
Application.OpenURL((string)_plat_data["appurl"]);
Application.Quit();
#endif
});
yield break;
}
}
Voice.VoiceUpload = json["voice_upload_url"] as string;
Voice.VoiceDownload = json["voice_download_url"] as string;
//GameApplication.PackVersion = server_version.pack_version;
if (!GameApplication.Instance.buildApp)
{
GameApplication.AppVersion.FillData(server_version);
_version_view.Dispose();
GameApplication.Instance.StartGame();
}
else
{
StartCoroutine(CheckAssetConfig(server_version));
}
}
else
{
ShowTip("版本检索失败,请检查您的网络设置!", () =>
{
StartCoroutine(CheckNet());
});
//yield break;
}
}
}
IEnumerator CheckAssetConfig(Version server_version)
{
GObject v_tex_info = _version_view.GetChild("tex_info");
GButton viewBtn_showWait = _version_view.GetChild("GlobalModalWaiting") as GButton;
Version local_version = Hotupdate.GetLocalVersion(string.Empty);
ArrayList asset_config_list = null;
string asset_config_text = null;
viewBtn_showWait.title = "正在连接服务器...";
if (local_version == null)
{
string ac_url = "";
if (isGFF == false)
ac_url = string.Format("{0}/config/asset_config{1}.json", Hotupdate.PackUrl, server_version.ToString());
else
2025-09-01 17:41:29 +08:00
ac_url = string.Format("http://{0}/NewFK/config/asset_config{1}.json", conn.ip + ":" + conn.port, server_version.ToString());
Debug.Log(ac_url);
float downTimeOut = 5;
using (var request = new WWW(ac_url))
{
float timeOut = Time.time;
float process = request.progress;
while (request != null && request.isDone == false)
{
if (process < request.progress)
{
timeOut = Time.time;
process = request.progress;
}
if (Time.time - timeOut > downTimeOut)
{
ShowTip("连接超时导致游戏配置下载异常,请检查您的网络设置!", () =>
{
StartCoroutine(CheckNet());
});
yield break;
}
yield return null;
}
yield return request;
if (string.IsNullOrEmpty(request.error))
{
asset_config_text = request.text;
asset_config_list = Json.Deserialize(asset_config_text) as ArrayList;
if (asset_config_list == null)
{
ShowTip("连接错误导致游戏配置下载异常,请检查您的网络设置!", () =>
{
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
}
//
v_tex_info.text = "正在检查资源。。。";
GSlider _pd = _version_view.GetChild("pb_progress").asSlider;
_pd.value = 0;
if (!Directory.Exists(ResourcesManager.PACK_PATH))
{
Directory.CreateDirectory(ResourcesManager.PACK_PATH);
}
string copyVersionPath = Path.Combine(Application.streamingAssetsPath, "version.txt");
2025-09-12 02:47:38 +08:00
#if UNITY_IPHONE
2025-09-13 16:58:49 +08:00
string copyVersionString = "";
2025-09-12 02:47:38 +08:00
if (File.Exists(copyVersionPath))
{
2025-09-13 16:58:49 +08:00
copyVersionString = File.ReadAllText(copyVersionPath).Trim();
}
else
{
ShowTip("本地缓存版本加载失败", () =>
{
File.WriteAllText(Path.Combine(ResourcesManager.PACK_PATH, "version.txt"), "1.0.0");
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
2025-09-12 02:47:38 +08:00
}
#endif
#if UNITY_ANDROID
UnityWebRequest copyRequest = UnityWebRequest.Get(copyVersionPath);
yield return copyRequest.SendWebRequest();
if (copyRequest.isNetworkError || copyRequest.isHttpError)
{
ShowTip("本地缓存版本加载失败", () =>
{
File.WriteAllText(Path.Combine(ResourcesManager.PACK_PATH, "version.txt"), "1.0.0");
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
}
2025-09-12 02:47:38 +08:00
string copyVersionString = copyRequest.downloadHandler.text.Trim();
2025-09-12 02:47:38 +08:00
#endif
bool isSame = copyVersionString.Equals(server_version.ToString());
if (isSame)
{
viewBtn_showWait.title = "正在解压资源...";
string copyZipPath = Path.Combine(Application.streamingAssetsPath, "Pack.byte");
2025-09-12 02:47:38 +08:00
#if UNITY_IPHONE
2025-09-22 17:27:49 +08:00
Byte[] zipData;
if (File.Exists(copyZipPath))
2025-09-13 16:58:49 +08:00
{
zipData = File.ReadAllBytes(copyZipPath);
}
else
2025-09-12 02:47:38 +08:00
{
2025-09-13 16:58:49 +08:00
ShowTip("本地缓存压缩包加载失败", () =>
{
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
2025-09-12 02:47:38 +08:00
}
2025-09-22 17:27:49 +08:00
/* if (zipData.LongLength < 1024)
{
ShowTip("本地缓存压缩包加载失败", () =>
{
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
}*/
string zipString = Path.Combine(Application.persistentDataPath, "Pack.byte");
File.WriteAllBytes(zipString, zipData);
2025-09-12 02:47:38 +08:00
#endif
#if UNITY_ANDROID
UnityWebRequest copyZipRequest = UnityWebRequest.Get(copyZipPath);
yield return copyZipRequest.SendWebRequest();
if (copyZipRequest.isNetworkError || copyZipRequest.isHttpError)
{
ShowTip("本地缓存压缩包加载失败", () =>
{
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
}
byte[] zipData = copyZipRequest.downloadHandler.data;
string zipString = Path.Combine(Application.persistentDataPath, "Pack.byte");
File.WriteAllBytes(zipString, zipData);
2025-09-22 17:27:49 +08:00
#endif
IFilePack zip = null;
zip = new FilePack20(zipString, PackMode.Read);
zip.UnPackFileSyn(ResourcesManager.PACK_PATH);
while (!zip.Complete)
{
_pd.value = zip.Progress*100;
yield return null;
}
StartCoroutine(CheckAssetConfig(server_version));
yield break;
}
else
{
File.WriteAllText(Path.Combine(ResourcesManager.PACK_PATH, "version.txt"), copyVersionString);
StartCoroutine(CheckAssetConfig(server_version));
yield break;
}
}
else
{
ShowTip("游戏资源下载失败,请检查您的网络设置!", () =>
{
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
}
}
}
else if (local_version.ContainAll(server_version))
{
string ac_url="";
if(isGFF==false)
ac_url = string.Format("{0}/config/asset_config{1}.json", Hotupdate.PackUrl, server_version.ToString());
else
2025-09-01 17:41:29 +08:00
ac_url = string.Format("http://{0}/NewFK/config/asset_config{1}.json", conn.ip + ":" + conn.port, server_version.ToString());
// Debugger.LogError("CheckAssetConfig===>>>");
Debugger.LogError(ac_url);
float downTimeOut = 5;
using (var request = new WWW(ac_url))
{
float timeOut = Time.time;
float process = request.progress;
while (request != null && request.isDone == false)
{
if (process < request.progress)
{
timeOut = Time.time;
process = request.progress;
}
if (Time.time - timeOut > downTimeOut)
{
ShowTip("连接超时导致游戏配置下载异常,请检查您的网络设置!", () =>
{
StartCoroutine(CheckNet());
});
yield break;
}
yield return null;
}
yield return request;
if (string.IsNullOrEmpty(request.error))
{
asset_config_text = request.text;
asset_config_list = Json.Deserialize(asset_config_text) as ArrayList;
if (asset_config_list == null)
{
ShowTip("连接错误导致游戏配置下载异常,请检查您的网络设置!", () =>
{
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
}
//
viewBtn_showWait.title = "正在下载资源...";
v_tex_info.text = "正在检查资源。。。";
GSlider _pd = _version_view.GetChild("pb_progress").asSlider;
//GObject v_tex_pd = _version_view.GetChild("tex_value");
_pd.value = 0;
//v_tex_pd.text = "0%";
bool ver_check = false;
StartCoroutine(VersionUpdateCheck(asset_config_list, (progress, finish) =>
{
_pd.value = progress * 100f;
//v_tex_pd.text = $"{Mathf.Floor(progress*100f)}%";
ver_check = finish;
}, v_tex_info));
while (!ver_check)
{
yield return null;
}
string arv = string.Format("{0}asset_config{1}.json", ResourcesManager.PACK_PATH, server_version.ToString());
File.WriteAllText(arv, asset_config_text, System.Text.Encoding.UTF8);
string rv = ResourcesManager.PACK_PATH + "version.txt";
File.WriteAllText(rv, server_version.ToString(), System.Text.Encoding.UTF8);
}
else
{
ShowTip("游戏资源下载失败,请检查您的网络设置!", () =>
{
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
}
}
}else
{
// string arv = string.Format("{0}asset_config{1}.json", ResourcesManager.PACK_PATH, server_version.ToString());
string arv =ResourcesManager.PACK_PATH+"asset_config"+server_version.ToString()+".json";
//Debug.LogError("ARV===>>>" + arv);
try
{
viewBtn_showWait.title = "快马加鞭进入游戏中...";
asset_config_text = File.ReadAllText(arv);
asset_config_list = Json.Deserialize(asset_config_text) as ArrayList;
foreach (Hashtable tem in asset_config_list)
{
string b_path = "base/" + tem["name"];
ResourcesManager.ReadAssetConfig(b_path);
}
}
catch (Exception s)
{
Debug.LogError(s.ToString());
ShowTip("游戏资源损坏,请重新安装新包!", () =>
{
StartCoroutine(CheckAssetConfig(server_version));
});
yield break;
}
//IEnumerator enumerator = asset_config_list.GetEnumerator();
//try
//{
// while (enumerator!=null && enumerator.MoveNext())
// {
// Hashtable hashtable = (Hashtable)enumerator.Current;
// string base_path = "base/" + hashtable["name"].ToString();
// ResourcesManager.ReadAssetConfig(base_path);
// yield return null;
// }
//}
//finally
//{
// IDisposable disposable;
// if ((disposable = (enumerator as IDisposable)) != null)
// {
// disposable.Dispose();
// }
//}
}
GameApplication.AppVersion.FillData(server_version);
v_tex_info.text = "正在加载资源请稍后。。";
//ResourcesManager.Init();
yield return null;
_version_view.Dispose();
GameApplication.Instance.StartGame();
}
/// <summary>
/// 检查基本更新包
/// </summary>
/// <param name="asset_config_list"></param>
/// <param name="onback"></param>
/// <param name="tip"></param>
/// <returns></returns>
IEnumerator VersionUpdateCheck(ArrayList asset_config_list, System.Action<float, bool> onback, FairyGUI.GObject tip)
{
Version local_version = Version.DEFUALT;
for(int i=0;i< asset_config_list.Count; ++i)
{
var tem = asset_config_list[i] as Hashtable;
//if (GameApplication.HideSdk)
//{
// if (!tem.ContainsKey("check")) continue;
// if (!(bool)tem["check"]) continue;
//}
string b_path = "base/" + tem["name"].ToString();
Hotupdate version_update = new Hotupdate(b_path + "/", local_version, new Version((string)tem["ver"]));
version_update.AssetName = b_path;
version_update.HideDetail = true;
#if UNITY_ANDROID && !UNITY_EDITOR
//if (GameApplication.Instance.isAndroid64bit==false)
//{
// if (tem["name"].ToString()=="base_script")
// {
// version_update.isBuild32lua = true;
// }
//}
#endif
version_update.SetTipCallback((text,callback)=>
{
ShowTip(text, callback);
});
version_update.LoadAsset();
while (!version_update.Done)
{
onback(version_update.Progress, false);
tip.text = version_update.TextTip;
yield return null;
}
ResourcesManager.ReadAssetConfig(b_path);
}
onback(1, true);
}
#if UNITY_ANDROID
IEnumerator DownApp(string appurl,string version)
{
var v_tex_info = _version_view.GetChild("tex_info");
v_tex_info.text = "正在下载新的安装包(0KB/0KB)";
var _pd = _version_view.GetChild("pb_progress").asSlider;
//GObject v_tex_pd = _version_view.GetChild("tex_value");
var request = new BestHTTP.HTTPRequest(new System.Uri(appurl));
request.EnableTimoutForStreaming = false;
request.UseStreaming = true;
request.IsKeepAlive = true;
request.Send();
var filePath = Application.persistentDataPath + "/update" + version + ".apk";
if (File.Exists(filePath))
{
File.Delete(filePath);
}
FileStream stream = null;
request.OnProgress = (originalRequest, downloaded, downloadLength) =>
{
v_tex_info.text = string.Format("正在下载新的安装包({0}KB/{1}KB)", downloaded / 1024, downloadLength / 1024);
_pd.value = (downloaded / (float)downloadLength) * 100;
//v_tex_pd.text = $"{Mathf.Floor((downloaded / (float)downloadLength) * 100)}%";
var fragments = originalRequest.Response.GetStreamedFragments();
if (fragments != null)
{
if (stream == null)
{
stream = File.Create(filePath);
}
foreach(byte[] buffer in fragments)
{
stream.Write(buffer, 0, buffer.Length);
}
}
};
while (request.State < BestHTTP.HTTPRequestStates.Finished)
{
yield return null;
}
yield return new WaitForSeconds(1);
stream.Dispose();
request.OnProgress = null;
if (request.State == BestHTTP.HTTPRequestStates.Finished && request.Response.IsSuccess)
{
DeleteOldPack();
PlatformAndroid.Instance.UpdateApp(filePath);
}
else
{
ShowTip("请检查您的网络设置!", () =>
{
StartCoroutine(DownApp(appurl, version));
});
}
}
#endif
public void ShowTip(string text, System.Action callback)
{
var ctr_state = _version_view.GetController("state");
ctr_state.selectedIndex = 1;
_version_view.GetChild("tex_tip").text = text;
_version_view.GetChild("btn_ok").onClick.Set(() =>
{
ctr_state.selectedIndex = 0;
if (callback != null) callback();
});
}
/// <summary>
/// 移除本地缓存包
/// </summary>
public static void DeleteOldPack()
{
string dir = ResourcesManager.RES_PATH;
string rv = dir + "version.txt";
if (File.Exists(rv)) File.Delete(rv);
if (Directory.Exists(dir)) Directory.Delete(dir, true);
}
}