//获取登陆服务器IP地址 static public void GetLoginServerConfig(Action <string, int> getServerConfigCB) { Action <string> getServerListAction = delegate(string serverListContent) { LoginServerConfig.LoadFromText(serverListContent, "LoginServerConfig"); string ip = ""; int port = 0; foreach (var item in dataMap) { ip = item.Value.ip; port = item.Value.port; break; } getServerConfigCB(ip, port); }; ServerURLManager.GetSeverListData(getServerListAction); }
//检查服务器和本地版本号 public void CheckLocalVersionInfoWithServer(System.Action <bool> updateFinish) { System.Action <string> getServerVersionFinish = delegate(string data) { //服务器版本 VersionInfo serverVersionInfo = VersionInfo.ParseData(data); m_serverVersionInfo = serverVersionInfo; if (serverVersionInfo.IsForceToUpdate) { SystemConfig.Instance.IsAutoUpdate = true; } if (!SystemConfig.Instance.IsAutoUpdate) { updateFinish(true); return; } //本地版本 GetLocalVersionInfoAsync((localVersionInfo) => { //苹果商店版本 if (InnerVersionInfo.IsAppleAppStore && serverVersionInfo.IsOpenAutoUpdateInAppStore == false) { updateFinish(true); return; } if (localVersionInfo.ProgramVersion < serverVersionInfo.ProgramVersion) { //整个客户端需要更新 System.Action clickAction = delegate() { if (Application.platform == RuntimePlatform.IPhonePlayer) { if (InnerVersionInfo.IsAppleAppStore) { Application.OpenURL(serverVersionInfo.IOSAppStoreUrl); } else { Application.OpenURL(serverVersionInfo.IOSAppUrl); } } else { Application.OpenURL(serverVersionInfo.ApkUrl); } }; //UIMsgBox.Instance.ShowMsgBoxOK(LanguageConfig.WordUpdate, "有新客户端发布了,点击按钮进行更新", "更新", clickAction, false); UIMsgBox.Instance.ShowMsgBoxOK(LanguageConfig.WordUpdate, LanguageConfig.GetText(3), LanguageConfig.WordUpdate, clickAction, false); Debug.Log("提示更新整包"); return; } //计算需要更新的资源 List <ResInfo> listResInfo = new List <ResInfo>(); foreach (KeyValuePair <string, ResInfo> item in serverVersionInfo.dictRes) { string key = item.Key; var resinfo = item.Value; if (localVersionInfo.dictRes.ContainsKey(item.Key)) { ResInfo localResInfo = localVersionInfo.dictRes[item.Key]; if (string.Compare(item.Value.resMD5, localResInfo.resMD5, true) != 0 && item.Value.resRequireID == 0) { listResInfo.Add(item.Value); } } else { //本地没有 if (item.Value.isResRequire && item.Value.resRequireID == 0) { listResInfo.Add(item.Value); } } } if (listResInfo.Count != 0) { //更新Lua脚本和资源 DownLoadRes(listResInfo, updateFinish); } else { updateFinish(true); } }); }; //获取服务器版本信息 ServerURLManager.GetVersionData(getServerVersionFinish); Debug.Log("获取服务器版本信息"); }