private void ReciveIPDetail(IPGeolocationDetail detail) { if (detail == null) { retryTimes++; if (retryTimes > 1) { retryTimes = 0; RunDownloadRegionServer(); } else { OnFlowStart(); } return; } iPGeolocationDetail = detail; if (detail.country_code == "CN") { IsChinaIP = true; } Debug.Log("IP地区:" + detail.ipv4 + " 国家:" + detail.country); GameInfoCollecter.AddNetworkStateInfoValue("Device IP", detail.ipv4); GameInfoCollecter.AddNetworkStateInfoValue("Device IP Country", detail.country); GameInfoCollecter.AddNetworkStateInfoValue("Device IP Country Code", detail.country_code); flowManager.SetVariable(P_IPGeolocationDetail, detail); RunDownloadRegionServer(); }
public static bool CheckLocalVersion() { try { string StreamPath = PathTool.GetAbsolutePath(ResLoadLocation.Streaming, c_versionFileName.ToLower()); //判断本地文件是否存在 if (!File.Exists(StreamPath)) { Debug.LogError("本地 Version 文件不存在,请先创建本地文件!"); return(false); } int s_bigVersion = 0; int s_smallVersion = 0; GetVersion(StreamPath, ref s_bigVersion, ref s_smallVersion); GameInfoCollecter.AddAppInfoValue("Streaming Bundle Version", s_bigVersion + "." + s_smallVersion); string persistentPath = PathTool.GetAssetsBundlePersistentPath() + c_versionFileName; //判断沙盒路径是否存在 if (!File.Exists(persistentPath)) { Debug.Log("沙盒 Version 文件不存在!"); return(false); } int p_bigVersion = 0; int p_smallVersion = 0; GetVersion(persistentPath, ref p_bigVersion, ref p_smallVersion); GameInfoCollecter.AddAppInfoValue("Persistent Bundle Version", p_bigVersion + "." + p_smallVersion); Debug.Log("largeVersionKey Streaming " + s_bigVersion + " 本地 " + p_bigVersion); Debug.Log("smallVersonKey Streaming " + s_smallVersion + " 本地 " + p_smallVersion); //Streaming版本如果比Persistent版本还要新,则更新Persistent版本 if (s_bigVersion > p_bigVersion || (s_bigVersion == p_bigVersion && s_smallVersion > p_smallVersion) || (s_bigVersion == p_bigVersion && s_smallVersion == p_smallVersion) ) { Debug.Log("Streaming版本比Persistent版本还要新"); MemoryManager.FreeMemory(); RecordManager.CleanRecord(c_HotUpdateRecordName); AssetsManifestManager.LoadAssetsManifest(); } return(true); } catch (Exception e) { Debug.LogError(e.ToString()); //UpdateDateCallBack(HotUpdateStatusEnum.UpdateFail, 0); } return(false); }
public void StartSelectServer(GameServerAreaData gameServerArea) { Debug.Log("开始选服"); if (ApplicationManager.Instance.m_AppMode == AppMode.Release) { RuntimePlatform platform = Application.platform; //if (Application.isEditor) //{ // if (platform == RuntimePlatform.OSXEditor) // platform = RuntimePlatform.IPhonePlayer; // else // { // platform = RuntimePlatform.Android; // } //} string defaultChannel = "GameCenter"; string channel = SDKManager.GetProperties(SDKInterfaceDefine.PropertiesKey_ChannelName, defaultChannel); GameInfoCollecter.AddNetworkStateInfoValue("渠道", channel); string selectNetworkPath = gameServerArea.m_SelectServerURL; SelectSeverController.Start(selectNetworkPath, Application.version, platform, channel, (data) => { SelectNetworkData select = null; bool isSelectRight = false; if (data == null || data.Count == 0) { Debug.LogError("没有合适的服务器!"); //return; string networkID = SDKManager.GetProperties("NetworkID", "3"); select = DataGenerateManager <SelectNetworkData> .GetData(networkID); } else { int r = UnityEngine.Random.Range(0, data.Count); select = data[r]; isSelectRight = true; } GameInfoCollecter.AddNetworkStateInfoValue("是否正确匹配服务器", isSelectRight); GameInfoCollecter.AddNetworkStateInfoValue("匹配服务器", select.m_serverIP + ":" + select.m_port); GameInfoCollecter.AddNetworkStateInfoValue("服务器描述", select.m_description); SelectServerCompleted(select); }); } else { if (OnSelectServerLocal != null) { OnSelectServerLocal(SelectServerCompleted); } } }
private static void OnUserLogoutEvent(UserLogout2Client e, object[] args) { isLogin = false; isClickLogin = false; ResendMessageManager.startResend = false; loginMsg = null; SDKManager.LoginOut(PlayerLoginPlatform.ToString()); GameInfoCollecter.AddPlayerInfoValue("IsLogin", IsLogin); if (OnUserLogout != null) { OnUserLogout(e); } }
/// <summary> /// 初始化 /// </summary> /// <param name="loadType"></param> /// <param name="useCache"></param> public static void Initialize(AssetsLoadType loadType, bool useCache) { //if (isInit) // return; if (loadType == AssetsLoadType.AssetBundle) { useCache = true; } if (!Application.isPlaying) { useCache = false; } UseCache = useCache; ResourceManager.loadType = loadType; ReleaseAll(); GameInfoCollecter.AddAppInfoValue("AssetsLoadType", loadType); loadAssetsController = new AssetsLoadController(loadType, useCache); //Debug.Log("ResourceManager初始化 AssetsLoadType:" + loadType + " useCache:" + useCache); }
public void Awake() { //Debug.Log("persistentDataPath:" + Application.persistentDataPath); instance = this; GameInfoCollecter.AddAppInfoValue("Build App Mode", m_AppMode); if (Application.platform != RuntimePlatform.WindowsEditor && Application.platform != RuntimePlatform.OSXEditor) { try { string modeStr = PlayerPrefs.GetString("AppMode", m_AppMode.ToString()); m_AppMode = (AppMode)Enum.Parse(typeof(AppMode), modeStr); } catch (Exception e) { Debug.LogError(e); } } AppLaunch(); }
private static void OnUserLoginEvent(UserLogin2Client e, object[] args) { activationCode = ""; if (e.code == 0) { isLogin = true; GameDataMonitor.PushData("User", e.user, "玩家数据"); GameInfoCollecter.AddPlayerInfoValue("IsLogin", IsLogin); GameInfoCollecter.AddPlayerInfoValue("UserID", e.user.userID); GameInfoCollecter.AddPlayerInfoValue("LoginType", e.user.loginType); GameInfoCollecter.AddPlayerInfoValue("NickName", e.user.nickName); GameInfoCollecter.AddPlayerInfoValue("TypeKey", e.user.typeKey); GameInfoCollecter.AddPlayerInfoValue("PlayTime", e.user.playTime); GameInfoCollecter.AddPlayerInfoValue("TotalLoginDays", e.user.totalLoginDays); SDKManager.UserID = e.user.userID; } if (OnUserLogin != null) { OnUserLogin(e); } if (e.reloginState) { return; } isClickLogin = false; if (e.code != 0) { Debug.LogError("Login error code:" + e.code); return; } ResendMessageManager.startResend = true; loginMsg.typeKey = e.user.typeKey; SDKManager.LogLogin(e.user.userID); }
/// <summary> /// 下载大区服务器列表 /// </summary> public void DownloadRegionServerList(string url, string country_code, Action <string, GameServerAreaData> OnCompleted) { DataTableExtend.DownLoadTableConfig <GameServerAreaData>(url, (dataList, urlError) => { if (!string.IsNullOrEmpty(urlError)) { Debug.LogError("DownloadRegionServerList download fail!"); if (OnCompleted != null) { OnCompleted("download fail! " + urlError, null); } return; } if (dataList.Count == 0) { Debug.LogError("DownloadRegionServerList GameServerAreaData is Empty!"); if (OnCompleted != null) { OnCompleted("GameServerAreaData is Empty!", null); } return; } if (!string.IsNullOrEmpty(country_code)) { //根据国家选择大区 foreach (var item in dataList) { if (ArrayContains(item.m_CountryCode, country_code)) { Debug.Log("国家选定大区key:" + item.m_key); GameInfoCollecter.AddNetworkStateInfoValue("选定大区", item.m_key); if (OnCompleted != null) { OnCompleted(null, item); } return; } } } //根据大洲选择大区 string continentName = GetContinentByCountryCode(country_code); if (!string.IsNullOrEmpty(continentName)) { foreach (var item in dataList) { if (ArrayContains(item.m_ContinentName, continentName)) { Debug.Log("根据大洲选定大区key:" + item.m_key); GameInfoCollecter.AddNetworkStateInfoValue("选定大区", item.m_key); if (OnCompleted != null) { OnCompleted(null, item); } return; } } } Debug.Log("使用ping选择大区:" + dataList.Count); List <string> specialServerHostList = new List <string>(); foreach (var item in dataList) { specialServerHostList.Add(item.m_SpecialServerHost); } UnityPingManager.PingGetOptimalItem(specialServerHostList.ToArray(), (statistics) => { Debug.Log("选出最优Ping:" + statistics); GameServerAreaData saData = null; foreach (var item in dataList) { if (item.m_SpecialServerHost == statistics.host) { saData = item; break; } } string error = null; if (saData == null) { error = "Select Ping Result Error!"; } if (OnCompleted != null) { OnCompleted(error, saData); } }); }); }