private static bool ProcessCommandLine(string[] args) { if (args.Length != 0) { if (args[0].Contains("info", StringComparison.OrdinalIgnoreCase)) { Logger.Warn("System info: {0}", OSUtility.OSString()); return(true); } else if (args[0].Contains("logfiletest", StringComparison.OrdinalIgnoreCase)) { if (args.Length != 6) { Console.WriteLine("Usage: log-filename regex-failure-filename regex-failure-timestamp-format regex-success-filename regex-success-timestamp-format"); Console.WriteLine("Can use a . to not specify the regex or timestamp format"); } else { IPBanLogFileTester.RunLogFileTest(args[1], args[2], args[3], args[4], args[5]); } return(true); } } return(false); }
//Model private void FunctionOfModelInterface() { string filename = ModelFilePath; string OSfile = OSFilePath; List <string> ErrorMessages = new List <string>(); JObject MainObject = OSUtility.JsonReader(filename); ModelValidator modelFile = new ModelValidator(); // Checking for main json of DcsPlus.APL.FP.Control.PIDConL.Home.json file modelFile.FullFile_Check(ref ErrorMessages, MainObject); // Checking for FaceplateFacetTypeName modelFile.FaceplateFacetTypeName_Check(ref ErrorMessages, filename, MainObject); // Checking for FaceplateFacetTypeInstance JObject FaceplateFacetTypeInstance = (JObject)MainObject["FaceplateFacetTypeInstance"]; modelFile.FaceplateFacetTypeInstance_Check(ref ErrorMessages, MainObject, FaceplateFacetTypeInstance); // Checking for FaceplateFacetType JObject FaceplateFacetType = (JObject)MainObject["FaceplateFacetType"]; JObject FaceplateFacetTypePropertyInterface = (JObject)MainObject["FaceplateFacetTypePropertyInterface"]; JArray PropertyInterface = (JArray)FaceplateFacetTypePropertyInterface["PropertyInterface"]; modelFile.FaceplateFacetType_Check(ref ErrorMessages, FaceplateFacetType, PropertyInterface); // Checking for FaceplateFacetTypePropertyInterface modelFile.CompareFaceplateFacetTypeProperty(ref ErrorMessages, OSUtility.JsonReader(OSfile), PropertyInterface); //Check if all Property Interface elements are present in the particular OS interface. OSUtility.LogErrorMessages(ErrorMessages); }
private static int GetLargeMemoryLimit(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; LuaScriptMgr.Push(L, OSUtility.GetLargeMemoryLimit()); return(CheckReturnNum(L, count, nRet)); }
private static int GetResponseMACString(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; LuaScriptMgr.Push(L, OSUtility.GetResponseMACString()); return(CheckReturnNum(L, count, nRet)); }
public static string GetVersionString() { if (OSUtility.GetOSVersionString != null) { return(OSUtility.GetOSVersionString()); } return("1.0.0"); }
private static int getMemotryStats(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; LuaScriptMgr.Push(L, OSUtility.getMemotryStats()); return(CheckReturnNum(L, count, nRet)); }
public static int RequestPhotoPermission(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; OSUtility.RequestPhotoPermission(); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); }
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) { //获取并解析你需要上传的数据。解析成string类型 var wrapper = (Dictionary <string, object>)MiniJson.JsonDecode(e.purchasedProduct.receipt); if (null == wrapper) { return(PurchaseProcessingResult.Complete); } var store = (string)wrapper ["Store"]; //下面的payload 即为IOS的验证商品信息的数据。即我们需要上传的部分。 var payload = (string)wrapper ["Payload"]; // For Apple this will be the base64 encoded ASN.1 receipt var pid = e.purchasedProduct.definition.id; var transactionID = e.purchasedProduct.transactionID; int purchaseType = 0; string receipt = ""; string udid = OSUtility.GetOpenUDID(); string signature = ""; #if UNITY_IOS || UNITY_IPHONE purchaseType = 1; //Apple Store EPlatformType.EPlatformType_AppStore receipt = payload; Debug.Log(string.Format("PID = {0} Payload = {1}", pid, receipt)); #elif UNITY_ANDROID purchaseType = 2; //Google Play EPlatformType.EPlatformType_GooglePlay var gpDetails = (Dictionary <string, object>)MiniJson.JsonDecode(payload); receipt = (string)gpDetails["signature"]; // 服务器待验证 签名数据 signature = (string)gpDetails["json"]; // 服务器待验证 订单信息 #endif //Write cache FileBilling.Instance.ReadFile(); FileBilling.CReceiptInfo entry = new FileBilling.CReceiptInfo(); entry.RoleId = _roleId; entry.ProductId = pid; entry.IsSucceed = true; entry.BillingType = purchaseType; entry.Receipt = payload; entry.TransactionId = transactionID; FileBilling.Instance.Update(purchaseType, entry); FileBilling.Instance.WriteFile(); // Post receipt for verify bool bPostSucceed = PostVerifyData(_roleId, _roleId, purchaseType, pid, transactionID, udid, receipt, signature, false, true); PURCHASE_INFO info = new PURCHASE_INFO(); info.iBillingType = purchaseType; info.strTransactionId = transactionID; info.strProductId = pid; info.strReceipt = receipt; _fnPurchaseCallback(true, info); return(PurchaseProcessingResult.Complete); }
public static int GetPhysMemoryUsedSize(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; long mem = OSUtility.GetPhysMemoryUsedSize(); LuaScriptMgr.Push(L, mem); return(CheckReturnNum(L, count, nRet)); }
//检查磁盘空间 public UpdateRetCode CheckDiskFreeSpace(long lCheckSize) { long lFreeDiskSpace = OSUtility.GetFreeDiskSpace(); if (lFreeDiskSpace != 0 && lFreeDiskSpace < lCheckSize) { return(UpdateRetCode.disk_no_space); } return(UpdateRetCode.success); }
public static int HasPhotoPermission(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; bool ret = OSUtility.HasPhotoPermission(); LuaScriptMgr.Push(L, ret); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); }
public static int IsMicrophoneAvailable(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; bool bEnable = OSUtility.IsMicrophoneAvailable(); LuaScriptMgr.Push(L, bEnable); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); }
public void TestGetUserNameIsActive() { bool result = OSUtility.UserIsActive("root"); Assert.AreEqual(result, OSUtility.UserIsActive("root")); result = OSUtility.UserIsActive(Environment.UserName); Assert.AreEqual(result, OSUtility.UserIsActive(Environment.UserName)); // try something not exist, make sure false Assert.IsFalse(OSUtility.UserIsActive("asdoijasdoajspdojaspdojaspodjaspodjs")); }
private void FunctionOfOSInterface() { // The current file json is represented as JObject for traversal of properties and values based on the files json structure JObject MainObject = OSUtility.JsonReader(AbsoluteFilePath); List <string> errorMessages = new List <string>(); List <int> memberIds = new List <int>(); const string members = "members"; const string id = "id"; JArray membersObjArr = (JArray)MainObject[members]; for (int j = 0; j < membersObjArr.Count(); j++) { var membersId = MainObject[members][j][id]; memberIds.Add((int)membersId); } List <I_OSInterfaceValidator> MainRequirementList = new List <I_OSInterfaceValidator> { new OSInterfaceMainValidator(), new OSInterfaceFirstMemberIdValidator() }; List <I_OSInterfaceValidator> MembersIdRequirementList = new List <I_OSInterfaceValidator> { new OSInterfaceMemberSequenceIdValidator(), new OSInterfaceMemberUniqueIdValidator() }; List <I_OSInterfaceValidator> MembersRequirementsList = new List <I_OSInterfaceValidator> { new OSInterfaceMembersAllValidator(), new OSInterfaceMemberPropsValidator(), new OSInterfaceMembersIdEdcIdValidator(), new OSInterfaceMembersNameValidator() }; foreach (var item in MainRequirementList) { item.ValidateOSInterface(MainObject, ref errorMessages, null); } foreach (var item in MembersIdRequirementList) { item.ValidateOSInterface(MainObject, ref errorMessages, memberIds); } for (int i = 0; i < membersObjArr.Count(); i++) //loop to iterate through all the elements of members array { JObject membersDictionary = (JObject)membersObjArr[i]; foreach (var item in MembersRequirementsList) { item.ValidateOSInterface(membersDictionary, ref errorMessages, null); } } OSUtility.LogErrorMessages(errorMessages); }
public string GetUserLanguageCode() { if (string.IsNullOrEmpty(StrLanguageCode)) { StrLanguageCode = ReadUserLanguageCode(UserLanguageFile); } if (!string.IsNullOrEmpty(StrLanguageCode)) { return(StrLanguageCode); } return(OSUtility.GetSystemLanguageCode()); }
public static int CopyTextToClipboard(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if ((count == 1) && LuaScriptMgr.CheckTypes(L, 1, typeof(string))) { var strText = LuaScriptMgr.GetString(L, 1); OSUtility.CopyTextToClipboard(strText); } else { LogParamError("CopyTextToClipboard", count); } return(CheckReturnNum(L, count, nRet)); }
private static int ShowAlertView(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(string)))) { string title = LuaScriptMgr.GetString(L, 1); string content = LuaScriptMgr.GetString(L, 2); OSUtility.ShowAlertView(title, content); } else { LogParamError("ShowAlertView", count); } return(CheckReturnNum(L, count, nRet)); }
public static int OpenUrl(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if ((count == 1) && LuaScriptMgr.CheckTypes(L, 1, typeof(string))) { var strUrl = LuaScriptMgr.GetString(L, 1); OSUtility.OpenUrl(strUrl); } else { LogParamError("OpenUrl", count); } return(CheckReturnNum(L, count, nRet)); }
public static int GetOpenUDID(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; if (count == 0) { string udid = OSUtility.GetOpenUDID(); LuaScriptMgr.Push(L, udid); } else { LogParamError("GetOpenUDID", count); LuaScriptMgr.Push(L, string.Empty); } return(CheckReturnNum(L, count, nRet)); }
void Awake() { DeviceLogger.Instance.WriteLogFormat("EntryPoint Awake Begin..."); #if UNITY_IPHONE || UNITY_ANDROID Application.targetFrameRate = 30; Screen.sleepTimeout = SleepTimeout.NeverSleep; #elif !UNITY_EDITOR && UNITY_STANDALONE_WIN Application.targetFrameRate = 60; #endif DontDestroyOnLoad(gameObject); OSUtility.SetAudioAmbient(); Application.lowMemory += OnLowMemory; DeviceLogger.Instance.WriteLogFormat("EntryPoint Awake End..."); }
void OnApplicationPause(bool pauseStatus) { SDK.PlatformControl.OnApplicationStateChange(pauseStatus); if (IsInited) { if (!pauseStatus) { if (_DesignWidth > 0 && _DesignHeight > 0) { OSUtility.SetDesignContentScale(_DesignWidth, _DesignHeight); } } else { LuaScriptMgr.Instance.CallLuaFunction("PauseGame"); } } }
/// <summary> /// IPBan main method /// </summary> /// <param name="args">Args</param> /// <returns>Task</returns> public static async Task Main(string[] args) { if (args.Length != 0 && (args[0].Equals("info", StringComparison.OrdinalIgnoreCase) || args[0].Equals("-info", StringComparison.OrdinalIgnoreCase))) { Logger.Warn("System info: {0}", OSUtility.OSString()); return; } IPBanService service = null; await IPBanServiceRunner.MainService(args, (CancellationToken cancelToken) => { service = IPBanService.CreateService <IPBanService>(); return(service.RunAsync(cancelToken)); }, (CancellationToken cancelToken) => { service?.Dispose(); return(Task.CompletedTask); }); }
public void ProcessPurchaseCache() { int purchaseType = 0; #if UNITY_IOS || UNITY_IPHONE purchaseType = 1; //Apple Store EPlatformType.EPlatformType_AppStore #elif UNITY_ANDROID purchaseType = 2; //Google Play EPlatformType.EPlatformType_GooglePlay #endif FileBilling.Instance.ReadFile(); var entry = FileBilling.Instance.Get(purchaseType); if (entry == null) { return; } Debug.Log("=================ProcessPurchaseCache=================="); string udid = OSUtility.GetOpenUDID(); string signature = ""; string receipt = entry.Receipt; bool isSucceed = entry.IsSucceed; string pid = entry.ProductId; string transactionID = entry.TransactionId; int roleIdCache = entry.RoleId; #if UNITY_IOS || UNITY_IPHONE #elif UNITY_ANDROID if (isSucceed) { // 成功后解析需要的订单信息 var gpDetails = (Dictionary <string, object>)MiniJson.JsonDecode(receipt); receipt = (string)gpDetails["signature"]; // 服务器待验证 签名数据 signature = (string)gpDetails["json"]; // 服务器待验证 订单信息 } #endif // Post receipt for verify PostVerifyData(_roleId, roleIdCache, purchaseType, pid, transactionID, udid, receipt, signature, true, isSucceed); }
/// <summary> /// IPBan main method /// </summary> /// <param name="args">Args</param> /// <returns>Task</returns> public static async Task Main(string[] args) { if (args.Length != 0 && (args[0].Equals("info", StringComparison.OrdinalIgnoreCase) || args[0].Equals("-info", StringComparison.OrdinalIgnoreCase))) { Logger.Warn("System info: {0}", OSUtility.OSString()); return; } IPBanService service = null; await IPBanServiceRunner.MainService(args, (CancellationToken cancelToken) => { service = IPBanService.CreateService <IPBanService>(); Logger.Warn("IPBan is free software created and refined over many years."); Logger.Warn("Please consider upgrading to the pro version for more advanced functions, shared ban lists and much more."); Logger.Warn("Learn more at https://ipban.com"); return(service.RunAsync(cancelToken)); }, (CancellationToken cancelToken) => { service?.Dispose(); return(Task.CompletedTask); }); }
IEnumerable InitGameCoroutine() { DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine Start..."); foreach (var item in PreInitGameCoroutine()) { yield return(item); } SetupPath(); HobaDebuger.GameLogLevel = WriteLogLevel; //IOS Application.persistentDataPath /var/mobile/Containers/Data/Application/app sandbox/Documents //Android /storage/emulated/0/Android/data/package name/files #if UNITY_IOS _DocPath = Application.persistentDataPath; _LibPath = Path.Combine(Application.persistentDataPath, "UpdateRes"); _TmpPath = Path.Combine(Application.persistentDataPath, "Tmp"); #elif UNITY_ANDROID _DocPath = Application.persistentDataPath; _LibPath = Path.Combine(Application.persistentDataPath, "UpdateRes"); _TmpPath = Path.Combine(Application.persistentDataPath, "Tmp"); #else _DocPath = Environment.CurrentDirectory; _LibPath = Path.Combine(Environment.CurrentDirectory, "UpdateRes"); _TmpPath = Path.Combine(Environment.CurrentDirectory, "Tmp"); #endif yield return(null); #if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS //初始化异常上报SDK CLogReport.Init(); yield return(null); #endif //初始化基础目录 { string path = EntryPoint.Instance.ResPath; path = path.Replace("file://", ""); LuaDLL.HOBA_Init(path, _DocPath, _LibPath, _TmpPath); } _VoiceDir = Path.Combine(_TmpPath, "Voice"); _CustomPicDir = Path.Combine(_TmpPath, "CustomPic"); _UserLanguageFile = Path.Combine(_DocPath, "userlanguage.txt"); _UserBillingFile = Path.Combine(_DocPath, "userbilling.bin"); _UserDataDir = Path.Combine(_DocPath, "UserData"); string strOSLanguage = OSUtility.GetSystemLanguageCode(); string strUserLanguage = GetUserLanguageCode(); if (!Directory.Exists(_LibPath)) { Directory.CreateDirectory(_LibPath); } if (!Directory.Exists(_VoiceDir)) { Directory.CreateDirectory(_VoiceDir); } if (!Directory.Exists(_CustomPicDir)) { Directory.CreateDirectory(_CustomPicDir); } if (!Directory.Exists(_UserDataDir)) { Directory.CreateDirectory(_UserDataDir); } LuaDLL.HOBA_DeleteFilesInDirectory(_VoiceDir); //清空Tmp目录 LuaDLL.HOBA_DeleteFilesInDirectory(_CustomPicDir); //清空Tmp目录 yield return(null); if (!File.Exists(_UserLanguageFile)) //创建语言配置文件 { WriteUserLanguageCode(strOSLanguage); } yield return(null); //目录信息 //#if (UNITY_EDITOR || UNITY_STANDALONE_WIN) // var pType = LTPlatformBase.ShareInstance().GetPlatformType(); // HobaDebuger.LogWarningFormat("LTPlatformType: {0}", pType.ToString()); // HobaDebuger.LogWarningFormat("AssetBundlePath: {0}", _AssetBundlePath); // HobaDebuger.LogWarningFormat("ResPath: {0}", ResPath); // HobaDebuger.LogWarningFormat("DocPath: {0}", _DocPath); // HobaDebuger.LogWarningFormat("LibPath: {0}", _LibPath); // HobaDebuger.LogWarningFormat("TmpPath: {0}", _TmpPath); // HobaDebuger.LogWarningFormat("ConfigPath: {0}", _ConfigPath); // HobaDebuger.LogWarningFormat("LuaPath: {0}", _LuaPath); // HobaDebuger.LogWarningFormat("VoiceDir: {0}", _VoiceDir); // HobaDebuger.LogWarningFormat("CustomPickDir: {0}", _CustomPicDir); // HobaDebuger.LogWarningFormat("OSLanguage: {0}, UserLanguage: {1}", strOSLanguage, strUserLanguage); // yield return null; //#endif //根据语言设置更新语言 ReadUpdateStringXmlFromResources(strUserLanguage); yield return(null); #if (UNITY_EDITOR || UNITY_STANDALONE_WIN) //只在windows下起作用 bool bDebugSetting = ReadDebugSettingXml(); // HobaDebuger.LogWarningFormat("DebugSetting: {0}", bDebugSetting); // HobaDebuger.LogWarningFormat("DebugSetting SkipUpdate: {0}, Shortcut: {1}, LocalData: {2}, LocalLua: {3}, Is1080P: {4}, FullScreen: {5}", // _DebugSetting.SkipUpdate, // _DebugSetting.ShortCut, // _DebugSetting.LocalData, // _DebugSetting.LocalLua, // _DebugSetting.Is1080P, // _DebugSetting.FullScreen); _SkipUpdate = _DebugSetting.SkipUpdate || File.Exists(Path.Combine(_DocPath, "skip.txt")); //HobaDebuger.LogWarningFormat("SkipUpdate: {0}", _SkipUpdate); #endif #if !UNITY_EDITOR && UNITY_STANDALONE_WIN if (_DebugSetting.Is1080P) { Screen.SetResolution(1920, 1080, _DebugSetting.FullScreen); } if (_DebugSetting.FPSLimit > 0) { Application.targetFrameRate = _DebugSetting.FPSLimit; } #endif //初始化平台SDK { GameUpdateMan.Instance.InitUpdateUI(); //显示更新界面 bool isFinish = false; int code = -1; LTPlatformBase.ShareInstance().InitSDK((_, resultCode) => { code = resultCode; isFinish = true; }); LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Start); //平台SDK打点:开始游戏 while (!isFinish) { yield return(null); } bool isInited = LTPlatformBase.ShareInstance().IsInited; var pType = LTPlatformBase.ShareInstance().GetPlatformType(); DeviceLogger.Instance.WriteLogFormat("LTPlatform InitSDK result:{0}, return code:{1}, platform type:{2}", isInited.ToString(), code.ToString(), pType.ToString()); if (!isInited) { // 初始化失败,弹窗提示,退出游戏 GameUpdateMan.Instance.HotUpdateViewer.SetCircle(false); string errStr = LTPlatformBase.ShareInstance().GetErrStr(code); yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, errStr, _UpdateStringConfigParams.PlatformSDKString_InitFailedTitle)); ExitGame(); yield break; } } { // copy base res #if UNITY_ANDROID string srcDir = "res_base"; string destDir = Path.Combine(Application.persistentDataPath, "res_base"); if (!Directory.Exists(destDir)) { Directory.CreateDirectory(destDir); } IsInstallFinished = File.Exists(destDir + "/.lock"); if (!IsInstallFinished) { DeviceLogger.Instance.WriteLog(string.Format("Begin RunInstallStage... from {0} to {1}", srcDir, destDir)); foreach (var item in GameUpdateMan.Instance.RunInstallStage(srcDir, destDir)) { yield return(item); } DeviceLogger.Instance.WriteLog("End RunInstallStage..."); } if (IsInstallFinished) { string lockFile = Path.Combine(destDir, ".lock"); StreamWriter writer = File.CreateText(lockFile); writer.Write(TotalSizeToCopy); writer.Close(); DeviceLogger.Instance.WriteLog("EntryPoint InitGameCoroutine EntryPoint.Instance.RunInstallStage() Success..."); } else { DeviceLogger.Instance.WriteLog("EntryPoint InitGameCoroutine EntryPoint.Instance.RunInstallStage() Failed!"); } yield return(null); #endif //在更新开始前,获取ServerConfig.xml #if UNITY_EDITOR || UNITY_STANDALONE_WIN { string configsDir = Path.Combine(_ResPath, "Configs"); string path = Path.Combine(configsDir, "ServerConfig.xml"); if (!ReadServerConfigXml(path)) { HobaDebuger.LogWarningFormat("Read ServerConfig Failed: {0}", path); } } #else { string url = EntryPoint.Instance.GetClientServerUrl().NormalizeDir() + "ServerConfig.xml"; string tmpPath = Path.Combine(EntryPoint.Instance.TmpPath, "ServerConfig.xml"); string errMsg; var code = Patcher.FetchByUrl(url, tmpPath, Downloader.DownloadMan.reqTimeOut, out errMsg); if (code == Downloader.DownloadTaskErrorCode.Success) { if (!ReadServerConfigXml(tmpPath)) { HobaDebuger.LogWarningFormat("Read ServerConfig Failed: {0}", url); } } else { HobaDebuger.LogWarningFormat("Download ServerConfig Failed: {0}, {1}", url, code); } } #endif yield return(null); DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine UpdateRoutine Start..."); //IAP Verify url init and check receipt cache. LTPlatformBase.ShareInstance().InitPurchaseVerifyUrl(_ServerConfigParams.GetPurchaseVerifyUrl()); LTPlatformBase.ShareInstance().ProcessPurchaseCache(); LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Start_Update); //平台SDK打点:开始更新 // App & 资源更新 foreach (var item in GameUpdateMan.Instance.UpdateRoutine()) { yield return(item); } LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_End_Update); //平台SDK打点:结束更新 DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine UpdateRoutine End..."); } //初始化pck包, 编辑器模式下不使用pck,策划编辑器模式下使用 #if !UNITY_EDITOR { string path = _ResPath; path = path.Replace("file://", ""); LuaDLL.HOBA_InitPackages(path); } #endif //FIX ME:: 加载不等待2帧 Windows崩溃 待查 yield return(null); //等待一帧,否则部分 Android 设置闪烁 yield return(null); //等待一帧,否则部分 Android 设置闪烁 ReadGameCustomConfigParams(); yield return(null); ReadWwiseBankConfigParams(); yield return(null); ReadWwiseSoundConfigParams(); yield return(null); ReadPlayerFollowCameraConfig(); yield return(null); CLogFile.Init(); yield return(null); CGameSession.Instance().PingInterval = GameCustomConfigParams.PingInterval; CGameSession.Instance().MaxProcessProtocol = GameCustomConfigParams.MaxProcessProtocol; CGameSession.Instance().MaxProcessSpecialProtocol = GameCustomConfigParams.MaxProcessSpecialProtocol; foreach (var item in InitGameInternal()) { yield return(item); } CleanupUpdateResources(); if (PanelLogo != null) { PanelLogo.SetActive(true); yield return(null); } string videoPath = System.IO.Path.Combine(Application.streamingAssetsPath, "TERA_BackgroundStory.mp4"); VideoManager.PlayVideo(videoPath, null, null, null, true); yield return(null); GFXConfig.Instance.Init(); foreach (var item in DoStartGame()) { yield return(item); } //DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine DoStartGame End..."); DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine End..."); //TestLoadResource("Assets/Outputs/Sfx/Scene/scene_chuansong_chuanzou01.prefab"); }
IEnumerable RequestServerListCoroutine(Action <bool> callback) { var patcher = Patcher.Instance; if (patcher.ServerListResult.IsRunning) { Common.HobaDebuger.LogWarning("RequestServerListCoroutine Start Failed, ServerList Downloading"); yield break; } _ServerInfoList.Clear(); bool isSuccessful = true; // 先请求JSON { string url = patcher.strDynamicServerDir + UpdateConfig.ServerListRelativePathJSON; string hostName = patcher.strDynamicServerHostName; string jsonFile = patcher.strServerListJSON; FileOperate.DeleteFile(jsonFile); //Common.HobaDebuger.LogWarning("Start DownloadServerListJSONFile"); patcher.DownloadServerListFile(url, hostName, jsonFile); //开启线程从中心服下载JSON文件 while (patcher.ServerListResult.IsRunning) { yield return(null); } var serverListJSON = new List <ServerInfo>(); var dlCode = patcher.ServerListResult.ErrorCode; if (dlCode != Downloader.DownloadTaskErrorCode.Success) { // 下载失败 Common.HobaDebuger.LogWarningFormat("DownloadServerListJSONFile Failed! DownloadTaskErrorCode: {0}", dlCode); isSuccessful = false; } else { var code = Patcher.ParseServerList(jsonFile, serverListJSON); if (code != UpdateRetCode.success) { // 解析失败 Common.HobaDebuger.LogWarningFormat("Read ServerListJson Failed!"); isSuccessful = false; } else { for (int i = 0; i < serverListJSON.Count; ++i) { string strUrl; if (!OSUtility.DNSResolve(2, serverListJSON[i].ip, out strUrl)) { serverListJSON[i].state = 3; Common.HobaDebuger.LogWarningFormat("ServerListJSON DNSResolve Failed! {0}", serverListJSON[i].ip); } else { if (serverListJSON[i].ip != strUrl) { Common.HobaDebuger.LogWarningFormat("ServerListJSON DNSResolve Change {0} To {1}", serverListJSON[i].ip, strUrl); } serverListJSON[i].ip = strUrl; } } } } AddToServerList(serverListJSON); } // 再请求XML { bool customServerList = false; List <ServerInfo> serverListXML = new List <ServerInfo>(); #if UNITY_EDITOR || UNITY_STANDALONE_WIN customServerList = ReadCustomServerListXml(serverListXML); #endif if (customServerList) { // 读取本地 AddToServerList(serverListXML); } else { // 从CDN下载 string url = HobaText.Format("{0}{1}", patcher.strClientServerDir, UpdateConfig.ServerListRelativePathXML); string hostName = patcher.strClientServerHostName; string xmlFile = patcher.strServerListXML; FileOperate.DeleteFile(xmlFile); patcher.DownloadServerListFile(url, hostName, xmlFile); //开启线程从CDN下载XML文件 while (patcher.ServerListResult.IsRunning) { yield return(null); } var dlCode = patcher.ServerListResult.ErrorCode; if (dlCode != Downloader.DownloadTaskErrorCode.Success) { // 下载失败 Common.HobaDebuger.LogWarningFormat("DownloadServerListXMLFile Failed! DownloadTaskErrorCode: {0} {1}", dlCode, patcher.ServerListResult.ErrMsg); isSuccessful = false; } else { var code = Patcher.ParseServerList(xmlFile, serverListXML); if (code != UpdateRetCode.success) { // 解析失败 Common.HobaDebuger.LogWarningFormat("Read ServerListXML Failed!"); isSuccessful = false; } else { for (int i = 0; i < serverListXML.Count; ++i) { string strUrl; if (!OSUtility.DNSResolve(2, serverListXML[i].ip, out strUrl)) { serverListXML[i].state = 3; Common.HobaDebuger.LogWarningFormat("ServerListXML DNSResolve Failed! {0}", serverListXML[i].ip); } else { if (serverListXML[i].ip != strUrl) { Common.HobaDebuger.LogWarningFormat("ServerListXML DNSResolve Change {0} To {1}", serverListXML[i].ip, strUrl); } serverListXML[i].ip = strUrl; } } } } AddToServerList(serverListXML); } } patcher.OnDynamicDownloadComplete(); if (callback != null) { callback(isSuccessful); } }
private IEnumerable DoStartGame() { LuaStatic.Load = CustomLoader; LuaStatic.LoadFromAssetsPath = LoadFromAssetsPath; LuaScriptMgr sm = LuaScriptMgr.Instance; yield return(null); foreach (var item in sm.Bind()) { yield return(item); } sm.Start(); yield return(null); try { sm.DoString("require [[init]]"); sm.DoString("require [[preload]]"); } catch (LuaScriptException e) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", e.Message); yield break; } yield return(null); var luaState = sm.GetLuaState(); if (luaState.L != IntPtr.Zero) { int oldTop = LuaDLL.lua_gettop(luaState.L); do { LuaDLL.lua_getglobal(luaState.L, "preload"); if (LuaDLL.lua_pcall(luaState.L, 0, 1, 0) != 0) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", LuaDLL.lua_tostring(luaState.L, -1)); yield break; } bool ret = LuaDLL.lua_toboolean(luaState.L, -1); LuaDLL.lua_pop(luaState.L, 1); if (ret) { break; } yield return(null); } while (true); LuaDLL.lua_settop(luaState.L, oldTop); yield return(null); } //设置scale sm.GetDesignWidthAndHeight(ref _DesignWidth, ref _DesignHeight); if (_DesignWidth > 0 && _DesignHeight > 0) { OSUtility.SetDesignContentScale(_DesignWidth, _DesignHeight); } yield return(null); try { if (!_BeForArtTest) { sm.CallLuaFunction("StartGame"); } else { sm.CallLuaFunction("SceneTest"); } _IsInited = true; } catch (LuaScriptException e) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", e.Message); _IsInited = false; } yield return(null); ReadResPath(); //读取C#端需要的lua路径 StartCoroutine(TickCoroutine().GetEnumerator()); yield return(null); }
public IEnumerable RunInstallStage(string srcDir, string destDir) { EntryPoint.Instance.PanelHotUpdate.SetActive(true); //新UI _HotUpdateViewer.SetInstallInfo(EntryPoint.Instance.UpdateStringConfigParams.UpdateString_PrepareForFirstTimeUse); _HotUpdateViewer.SetInstallPercent(-1.0f); _HotUpdateViewer.SetAllProgress(0.0f); _HotUpdateViewer.SetPartProgress(0.0f); _HotUpdateViewer.SetDesc(EntryPoint.Instance.UpdateStringConfigParams.UpdateString_PrepareForFirstTimeUse); _HotUpdateViewer.SetCurrentVersion("0.0.0"); _HotUpdateViewer.SetServerVersion("0.0.0"); yield return(null); yield return(null); long lDiskSize = OSUtility.GetFreeDiskSpace(); long lTotalSize = (long)Math.Ceiling(EntryPoint.Instance.TotalSizeToCopy * 1.1f); if (lDiskSize != 0 && lDiskSize < lTotalSize) //没有足够的空间,退出 { string sizeStr = string.Empty; long iNeedSizeMB = lTotalSize / (1024 * 1024); if (iNeedSizeMB >= 1f) { iNeedSizeMB = ((iNeedSizeMB * 10) - (iNeedSizeMB * 10) % 1) / 10; //保留一位小数 if (iNeedSizeMB % 1 > 0) { //有小数点 sizeStr = HobaText.Format("{0:0.0} MB", iNeedSizeMB); } else { sizeStr = HobaText.Format("{0:0} MB", iNeedSizeMB); } } else { long iNeedSizeKB = lTotalSize / 1024; sizeStr = HobaText.Format("{0:0} KB", iNeedSizeKB); } _HotUpdateViewer.SetCircle(false); yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, EntryPoint.Instance.UpdateStringConfigParams.UpdateString_EnsureEnoughSpaceMB, EntryPoint.Instance.UpdateStringConfigParams.UpdateState_DiskSpaceFullErr, string.Empty, sizeStr)); EntryPoint.ExitGame(); yield break; } lTotalSize = EntryPoint.Instance.TotalSizeToCopy; bool succeed = false; float fLastProgress = 0.0f; var listFile = EntryPoint.Instance.ListFilesToCopy; if (lTotalSize > 0 && listFile != null) { long sizeFinished = 0; for (int i = 0; i < listFile.Count; ++i) { long size = CStreamingAssetHelper.CopyAssetFileToPath(listFile[i], srcDir, destDir); if (size == -1) { DeviceLogger.Instance.WriteLog(string.Format("RunInstallStage CopyAssetFileToPath Failed! {0}", listFile[i])); continue; } sizeFinished += size; float progress = (float)sizeFinished / lTotalSize; if (Util.IsZero(fLastProgress - progress)) { fLastProgress = progress; _HotUpdateViewer.SetAllProgress(progress); _HotUpdateViewer.SetPartProgress(progress); _HotUpdateViewer.SetInstallPercent(progress); yield return(null); yield return(null); } } succeed = (sizeFinished == lTotalSize); } else { succeed = true; } EntryPoint.Instance.IsInstallFinished = succeed; yield return(new WaitForSeconds(0.5f)); }
public IEnumerable UpdateRoutine() { //检查系统内存 /* * if (SystemInfo.systemMemorySize < nMemoryMinimum) * { * yield return new WaitForUserClick(MessageBoxStyle.MB_YesNo, * HobaText.Format(EntryPoint.Instance.UpdateStringConfigParams.SystemRequire_Memory, nMemoryMinimum), * UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError)); * * if (WaitForUserClick.RetCode == 0) * { * Patcher.Instance.UpdateExit(); * EntryPoint.ExitGame(); * yield break; * } * } * */ LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update); //平台SDK打点:检查更新 yield return(null); //更新资源,测试 { string baseDir = EntryPoint.Instance.ResPath; string docDir = EntryPoint.Instance.DocPath; string libDir = EntryPoint.Instance.LibPath; string tmpDir = EntryPoint.Instance.TmpPath; string updateServerDir1 = EntryPoint.Instance.GetUpdateServerUrl1(); string updateServerDir2 = EntryPoint.Instance.GetUpdateServerUrl2(); string updateServerDir3 = EntryPoint.Instance.GetUpdateServerUrl3(); string clientServerDir = EntryPoint.Instance.GetClientServerUrl(); string dynamicServerDir = EntryPoint.Instance.GetDynamicServerUrl(); string dynamicAccountRoleDir = EntryPoint.Instance.GetDynamicAccountRoleUrl(); foreach (var item in Patcher.Instance.Init(baseDir, docDir, libDir, tmpDir, updateServerDir1, updateServerDir2, updateServerDir3, clientServerDir, dynamicServerDir, dynamicAccountRoleDir)) { yield return(item); } //设置初始版本 #if UNITY_EDITOR //|| UNITY_STANDALONE_WIN Patcher.Instance.CleanAllUpdatesReturnToBase(Patcher.Instance.BaseVersion); #else string baseVersion = CPlatformConfig.GetBaseVersion(); bool bWriteVersion = Patcher.Instance.SetFirstVersion(baseVersion, false); if (bWriteVersion) { Patcher.Instance.CleanAllUpdatesReturnToBase(Patcher.Instance.BaseVersion); } #endif bool bSkipPhase2 = false; UpdateRetCode retCode = UpdateRetCode.success; UpdateStartPhase1: //阶段1... int nTryTime = 0; do { _HotUpdateViewer.SetInstallPercent(-1.0f); foreach (var item in Patcher.UpdateCoroutinePhase1()) { CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo(); _HotUpdateViewer.SetPartProgress(updateInfo.curUpdateProgress); _HotUpdateViewer.SetAllProgress(updateInfo.totalUpdateProgress); _HotUpdateViewer.SetDesc(updateInfo.strUpdateInfo); //新UI _HotUpdateViewer.SetCurrentVersion(updateInfo.curVersion); _HotUpdateViewer.SetServerVersion(updateInfo.serverVersion); yield return(null); if (item is UpdateRetCode) { retCode = (UpdateRetCode)item; break; } yield return(item); } m_CurrentVersion = Patcher.Instance.m_CurrentVersion.ToString(); m_ServerVersion = Patcher.Instance.m_VersionMan.VerLastest.ToString(); if (retCode != UpdateRetCode.success) //错误处理 { if (nTryTime == 0) { _HotUpdateViewer.SetCircle(false); yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_NetworkErr), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError))); UpdateInfoUtil.SetCanPlay(false); //重试 } else { LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败 _HotUpdateViewer.SetCircle(false); yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_NetConnectionErr), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError))); #if !UNITY_EDITOR Patcher.Instance.UpdateExit(); EntryPoint.ExitGame(); yield break; #else //忽略错误,直接游戏 retCode = UpdateRetCode.success; bSkipPhase2 = true; break; #endif } ++nTryTime; } else //成功 { if (IsVersionCanUpdate() && !IsVersionComplete()) { long downloadSize = GetDownloadTotalSize(); string num = string.Empty; float fMB = downloadSize / (1024.0f * 1024.0f); if (fMB >= 1f) { fMB = ((fMB * 10) - (fMB * 10) % 1) / 10; //保留一位小数 if (fMB % 1 > 0) { //有小数点 num = HobaText.Format("{0:0.0} MB", fMB); } else { num = HobaText.Format("{0:0} MB", fMB); } } else { float fKB = downloadSize / 1024.0f; num = HobaText.Format("{0:0} KB", fKB); } //下载总量提示 _HotUpdateViewer.SetCircle(false); yield return(new WaitForUserClick(MessageBoxStyle.MB_OkCancel, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_DownloadCheck), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_BeginUpdate), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_WifiTips), num)); if (WaitForUserClick.RetCode == 0) { LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败 Patcher.Instance.UpdateExit(); EntryPoint.ExitGame(); yield break; } //存储空间检查,提示 long lDiskSize = OSUtility.GetFreeDiskSpace(); long lNeedSize = (long)(downloadSize * fExtraSpace) + 100 * 1024 * 1024; Patcher.Instance.LogString(HobaText.Format("CheckDownloadSize! FreeDiskSize: {0}, NeedSize: {1}", lDiskSize, lNeedSize)); if (lDiskSize != 0 && lDiskSize < lNeedSize) { LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败 long iNeedSizeMB = lNeedSize / (1024 * 1024); string strNoSpaceMessage = HobaText.Format(EntryPoint.Instance.UpdateStringConfigParams.SystemRequire_Space, iNeedSizeMB); yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, strNoSpaceMessage, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalError))); Patcher.Instance.UpdateExit(); EntryPoint.ExitGame(); yield break; } _HotUpdateViewer.StartPromotion(); } break; //确认下载,进入下一阶段 } } while (true); if (!bSkipPhase2 && retCode == UpdateRetCode.success) { yield return(new WaitForSeconds(0.2f)); if (!IsVersionComplete() && !bWifiMsgBoxShow) //需要下载更新包,如果不是wifi需要提示 { if (OSUtility.IsNetAvailable() && !OSUtility.IsWifi()) { _HotUpdateViewer.SetCircle(false); yield return(new WaitForUserClick(MessageBoxStyle.MB_OkCancel, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasErrorNotWifi), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError))); bWifiMsgBoxShow = true; if (WaitForUserClick.RetCode == 0) { LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败 Patcher.Instance.UpdateExit(); EntryPoint.ExitGame(); yield break; } //继续 } } //阶段2... do { foreach (var item in Patcher.UpdateCoroutinePhase2()) { CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo(); _HotUpdateViewer.SetPartProgress(updateInfo.curUpdateProgress); _HotUpdateViewer.SetAllProgress(updateInfo.totalUpdateProgress); _HotUpdateViewer.SetDesc(updateInfo.strUpdateInfo); _HotUpdateViewer.SetCurrentVersion(updateInfo.curVersion); _HotUpdateViewer.SetServerVersion(updateInfo.serverVersion); yield return(null); if (item is UpdateRetCode) { retCode = (UpdateRetCode)item; break; } else { yield return(item); } } if (retCode == UpdateRetCode.pack_err || //包错误, 严重错误,需要清空所有更新目录重试 retCode == UpdateRetCode.pack_open_err || retCode == UpdateRetCode.pack_read_err || retCode == UpdateRetCode.pack_write_err) { _HotUpdateViewer.SetCircle(false); yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalErrorNeedCleanUp), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalError))); yield return(new WaitForSeconds(1.0f)); //上次写包错误,这时需要删除所有更新包,从基础版本重新更新,待测试 Patcher.Instance.CleanAllUpdatesReturnToBase(Patcher.Instance.BaseVersion); UpdateInfoUtil.SetCanPlay(false); //重试 yield return(new WaitForSeconds(1.0f)); goto UpdateStartPhase1; //重新开始更新,阶段1 } else if (retCode == UpdateRetCode.patcher_version_too_new) //版本太老,不能通过自动更新解决, 需要重新下载程序 { _HotUpdateViewer.SetCircle(false); #if UNITY_STANDALONE_WIN //FIXME:: 原逻辑版本不一致都不能进入游戏, 策划需求Windows 特殊处理点取消进入游戏,忽略程序版本限制 yield return(new WaitForUserClick(MessageBoxStyle.MB_OkCancel, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalErrorNeedReinstall), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_BeginUpdate))); if (WaitForUserClick.RetCode == 0) { retCode = UpdateRetCode.success; //走Phase3 break; } else { Patcher.Instance.UpdateExit(); EntryPoint.ExitGame(); yield break; } #else //FIXME:: 原逻辑 LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败 #if PLATFORM_KAKAO while (true) { yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalErrorNeedReinstall), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_BeginUpdate))); string url = string.Empty; if (Application.platform == RuntimePlatform.Android) { string id = "com.longtugame.xxaxc"; //写死 url = string.Format("market://details?id={0}", id); } else if (Application.platform == RuntimePlatform.IPhonePlayer) { string id = "1073000645"; //写死 url = string.Format("itms-apps://itunes.apple.com/app/id{0}?action=write-review", id); } Patcher.Instance.LogString(string.Format("OpenUrl:{0}", url)); OSUtility.OpenUrl(url); //跳转到商店 yield return(null); yield return(null); } #else // 非Kakao平台 yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalErrorNeedReinstall), UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_BeginUpdate))); Patcher.Instance.UpdateExit(); EntryPoint.ExitGame(); yield break; #endif #endif } else if (retCode == UpdateRetCode.pack_file_broken) //某些安卓机型上出现解包错误,重启app继续更新即可 { LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败 _HotUpdateViewer.SetCircle(false); CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo(); yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, updateInfo.strUpdateInfo, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError))); { Patcher.Instance.UpdateExit(); #if UNITY_ANDROID AndroidUtil.DoRestart(200); #else EntryPoint.ExitGame(); #endif yield break; } } else if (retCode != UpdateRetCode.success) //普通错误处理 { CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo(); string msgText = string.Format("{0} {1}", updateInfo.strUpdateInfo, retCode.ToString()); _HotUpdateViewer.SetCircle(false); yield return(new WaitForUserClick(MessageBoxStyle.MB_OkCancel, msgText, UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError))); if (WaitForUserClick.RetCode == 0) { #if !UNITY_EDITOR LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败 Patcher.Instance.UpdateExit(); EntryPoint.ExitGame(); yield break; #else retCode = UpdateRetCode.success; //走Phase3 break; #endif } else { UpdateInfoUtil.SetCanPlay(false); //重试 } } else //成功 { break; } } while (true); } Patcher.Instance.ReleasePackages(); //第三阶段,下载服务器列表 if (retCode == UpdateRetCode.success) { _HotUpdateViewer.SetCircle(false); _HotUpdateViewer.PrepareEnterGame(); //_HotUpdateViewer.SetInstallPercent(-1.0f); //yield return new WaitForSeconds(0.2f); float progress = 0f; float count = 0; foreach (var item in Patcher.UpdateCoroutinePhase3()) { CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo(); _HotUpdateViewer.SetPartProgress(updateInfo.curUpdateProgress); _HotUpdateViewer.SetAllProgress(updateInfo.totalUpdateProgress); _HotUpdateViewer.SetDesc(updateInfo.strUpdateInfo); _HotUpdateViewer.SetCurrentVersion(updateInfo.curVersion); _HotUpdateViewer.SetServerVersion(updateInfo.serverVersion); //新UI _HotUpdateViewer.SetInstallInfo(updateInfo.strUpdateInfo); _HotUpdateViewer.SetEnterGameTips(updateInfo.strUpdateInfo); //模拟进度条 _HotUpdateViewer.SetEnterGameProgress(progress); float maxProgress = (count < 2) ? 0.5f : 1f; progress = UnityEngine.Random.Range(progress, maxProgress); count++; yield return(null); if (item is UpdateRetCode) { retCode = (UpdateRetCode)item; break; } else { yield return(item); } } if (retCode != UpdateRetCode.success) { yield return(new WaitForSeconds(1.0f)); UpdateInfoUtil.SetCanPlay(false); } else { _HotUpdateViewer.SetEnterGameProgress(1f); yield return(new WaitForSeconds(0.3f)); UpdateInfoUtil.SetCanPlay(true); } } } Patcher.Instance.UpdateExit(); if (UpdateInfoUtil.GetUpdateInfo().bCanPlay) { _IsUpdateSucceed = true; yield return(null); } //yield return new WaitForSeconds(2.0f); }
//第一阶段更新,取得本地版本和服务器版本,下载服务器版本信息 public static IEnumerable UpdateCoroutinePhase1() { //初始化 UpdateInfoUtil.SetProgress(UPDATE_PROGRESS.Total, 0.0f); UpdateInfoUtil.SetProgress(UPDATE_PROGRESS.File, 0.0f); UpdateInfoUtil.SetCanPlay(false); //取得本地版本 UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateStatus_TryGetLocalVersion); yield return(null); var code = Patcher.Instance.GetLocalVersion(); if (code != UpdateRetCode.success) //无法取得本地版本 { UpdateInfoUtil.SetCanPlay(false); yield return(new WaitForSeconds(1.0f)); UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateState_GetLocalVersionErr); Patcher.Instance.LogString("GetLocalVersion Failed!"); yield return(code); } else { //设置本地版本 UpdateInfoUtil.SetVersion(UPDATE_VERSION.Local, Patcher.Instance.m_CurrentVersion); } //log Patcher.Instance.LogString(HobaText.Format("Client Current Version: {0}", Patcher.Instance.m_CurrentVersion.ToString())); Patcher.Instance.LogString(HobaText.Format("FreeDiskSpace: {0}", OSUtility.GetFreeDiskSpace())); //检查磁盘空间 /* * UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateStatus_TryCheckFreeSpace); * yield return null; * code = Patcher.Instance.CheckDiskFreeSpace(nCheckFreeSpaceMB * 1024 * 1024); * if (code != UpdateRetCode.success) * { * UpdateInfoUtil.SetCanPlay(false); * yield return new WaitForSeconds(1.0f); * * UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateState_DiskSpaceFullErr); * * Patcher.Instance.LogString("CheckDiskFreeSpace Failed!"); * yield return code; * } */ //test /* * string url = "https://www.google.com"; * string hostName = UpdateUtility.GetHostName(url); * string errMsg1; * var code1 = UpdateUtility.GetByUrl(url, hostName, System.IO.Path.Combine(EntryPoint.Instance.DocPath, "google.txt"), 10, null, null, out errMsg1); * Patcher.Instance.LogString(HobaText.Format("Download Test: {0} {1} {2}", url, code1, errMsg1)); */ if (!EntryPoint.Instance.SkipUpdate) //配置跳过更新 { //DNS解析, 忽略解析错误 UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateStatus_TryDNSResolving); yield return(null); string errUpdateServer; string errClientServer; code = Patcher.Instance.DNSResolving(2, out errUpdateServer, out errClientServer); if (!string.IsNullOrEmpty(errUpdateServer)) { Patcher.Instance.LogString("UpdateServer DNSResolving Error : " + errUpdateServer); } if (!string.IsNullOrEmpty(errClientServer)) { Patcher.Instance.LogString("errClientServer DNSResolving Error : " + errClientServer); } Patcher.Instance.LogString(string.Format("IP URL UpdateServer1: {0}, UpdateServer2: {1}, UpdateServer3: {2}", Patcher.Instance.strUpdateServerDir1, Patcher.Instance.strUpdateServerDir2, Patcher.Instance.strUpdateServerDir3)); Patcher.Instance.LogString(string.Format("IP URL ClientServer: {0}", Patcher.Instance.strClientServerDir)); Patcher.Instance.LogString(string.Format("IP URL DynamicServer : {0}", Patcher.Instance.strDynamicServerDir)); Patcher.Instance.LogString(string.Format("IP URL DynamicAccountRole : {0}", Patcher.Instance.strDynamicAccountRoleDir)); //从服务器获取version.txt UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateStatus_TryGetNewVersion); yield return(null); string errMsg = ""; string savedFile = Patcher.Instance.strGameNewVerFile; DownloadTaskErrorCode dlCode = DownloadTaskErrorCode.Unknown; { //为了方便部署,内网version.txt用和更新资源jup同一目录,也就是cdn if (dlCode != DownloadTaskErrorCode.Success && !string.IsNullOrEmpty(Patcher.Instance.strUpdateServerDir1)) { string url1 = Patcher.Instance.strUpdateServerDir1 + UpdateConfig.VersionConfigRelativePath; string hostName1 = Patcher.Instance.strUpdateServerHostName1; int nTryConnect = 0; //尝试多次连接 while (dlCode != DownloadTaskErrorCode.Success && nTryConnect < DownloadMan.maxTryConnect) { ++nTryConnect; int timeout = (int)((float)DownloadMan.reqTimeOut * nTryConnect / DownloadMan.maxTryConnect); dlCode = Patcher.Instance.FetchServerVersionFile(url1, hostName1, savedFile, timeout, out errMsg); } } if (dlCode != DownloadTaskErrorCode.Success && !string.IsNullOrEmpty(Patcher.Instance.strUpdateServerDir2)) { string url2 = Patcher.Instance.strUpdateServerDir2 + UpdateConfig.VersionConfigRelativePath; string hostName2 = Patcher.Instance.strUpdateServerHostName2; int nTryConnect = 0; //尝试多次连接 while (dlCode != DownloadTaskErrorCode.Success && nTryConnect < DownloadMan.maxTryConnect) { ++nTryConnect; int timeout = (int)((float)DownloadMan.reqTimeOut * nTryConnect / DownloadMan.maxTryConnect); dlCode = Patcher.Instance.FetchServerVersionFile(url2, hostName2, savedFile, DownloadMan.reqTimeOut, out errMsg); } } if (dlCode != DownloadTaskErrorCode.Success && !string.IsNullOrEmpty(Patcher.Instance.strUpdateServerDir3)) { string url3 = Patcher.Instance.strUpdateServerDir3 + UpdateConfig.VersionConfigRelativePath; string hostName3 = Patcher.Instance.strUpdateServerHostName3; int nTryConnect = 0; //尝试多次连接 while (dlCode != DownloadTaskErrorCode.Success && nTryConnect < DownloadMan.maxTryConnect) { ++nTryConnect; int timeout = (int)((float)DownloadMan.reqTimeOut * nTryConnect / DownloadMan.maxTryConnect); dlCode = Patcher.Instance.FetchServerVersionFile(url3, hostName3, savedFile, DownloadMan.reqTimeOut, out errMsg); } } } if (dlCode != DownloadTaskErrorCode.Success) { UpdateInfoUtil.SetCanPlay(false); yield return(new WaitForSeconds(1.0f)); UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateState_GetNewVersionErr); if (dlCode == DownloadTaskErrorCode.Md5Dismatch) { code = UpdateRetCode.md5_not_match; } else { code = UpdateRetCode.download_fail; } Patcher.Instance.LogString("FetchServerVersionFile Failed! DownloadTaskErrorCode: " + dlCode + ": " + errMsg); yield return(code); } //读取游戏新版本信息 code = Patcher.Instance.TryGetLatestVersionFromServer(); } else { //读取游戏新版本信息 code = UpdateRetCode.success; } if (code != UpdateRetCode.success) { UpdateInfoUtil.SetCanPlay(false); yield return(new WaitForSeconds(1.0f)); UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateState_GetNewVersionErr); Patcher.Instance.LogString("GetVersionMan Failed!"); yield return(code); } else { //设置服务器版本 UpdateInfoUtil.SetVersion(UPDATE_VERSION.Server, Patcher.Instance.m_VersionMan.VerLastest); } //log Patcher.Instance.LogString(HobaText.Format("Server Version: {0}", Patcher.Instance.m_VersionMan.VerLastest.ToString())); UpdateInfoUtil.SetDownloadTotalSize(GameUpdateMan.Instance.GetDownloadTotalSize()); UpdateInfoUtil.SetCanPlay(false); UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateStatus_SuccessGetVersions); yield return(code); }