public void Initialize() { if (VERSION_CODE.Length >= 0) { return; } if (Application.isEditor) { VERSION_CODE = "100"; } else { VERSION_CODE = BundleGlobal.AppVersion()["versionName"].Split('.')[3]; Debug.Log("BundleGlobal.AppVersion "); } m_strLogPath = BundleGlobal.LocalPath + "log.txt"; m_strErrorPath = BundleGlobal.LocalPath + "error.txt"; if (File.Exists(m_strLogPath)) { File.Delete(m_strLogPath); } if (File.Exists(m_strErrorPath)) { StartCoroutine(Upload()); } Application.RegisterLogCallback(HandleLog); }
void OnChargeBtn(GameObject go) { foreach (ChargeInfo chargeInfo in _chargeInfos) { if (go == chargeInfo.chargeBtn) { if (chargeInfo.monthCardId != 0) { return; } // GHome.GetInstance().Pay("", BundleGlobal.AppVersion()["Area"], chargeInfo.productCode, "", (code, msg, data) => { if (code == Constants.ERROR_CODE_SUCCESS) { } else { } }); return; } } }
void LoginGHome(bool bActiveUI) { GHome.GetInstance().Login((code, msg, data) => { Debug.Log("Login callback code: " + code + " msg: " + msg); if (code == 0) { GHome.GetInstance().LoginArea(BundleGlobal.AppVersion()["Area"]); Debug.Log("CallBack Success."); SDGlobal.phoneNumber = (string)data["userId"]; SDGlobal.ticket = (string)data["ticket"]; if (bActiveUI) { if (m_btEnterGameButton) { m_btEnterGameButton.SetActive(true); } if (m_btGameServer) { m_btGameServer.SetActive(true); } if (m_btSystemNotice) { m_btSystemNotice.SetActive(true); } if (m_btPlayVideo) { string str = sdConfDataMgr.Instance().GetSetting("firstEnter"); m_btPlayVideo.SetActive(str.Length != 0); } } if (m_gHomeAccountButton) { if (bActiveUI) { m_gHomeAccountButton.SetActive(true); } UILabel buttonLabel = m_gHomeAccountButton.GetComponentInChildren <UILabel>(); if (buttonLabel) { //buttonLabel.text = SDGlobal.phoneNumber.Replace("+86", ""); } } Debug.Log("CallBack Success. OK!"); GHOME_CODE = 0; } else if (code == -1) { Debug.Log("code == -1"); //GHOME_CODE = -1; } else { SDGlobal.gHomeLoginActivate = true; GHOME_CODE = 1; Debug.Log("Login Error Code=" + code); } }); }
IEnumerator UpdateProcess() { //APK Update #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { glupgrade.gluInit(); glupgrade.getCallback()._onDownloadChange = OnProcessChanged; glupgrade.getCallback()._onMD5CheckStart = OnMD5CheckStart; glupgrade.getCallback()._onMD5CheckFinish = OnMD5CheckFinish; glupgrade.getCallback()._onDownloadStart = OnDownloadStart; glupgrade.getCallback()._onDownloadFinish = OnDownloadFinished; if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(true); m_slUpdateBar.value = 0.0f; } bool ApkUpdate = false; while (true) { if (SDGlobal.apkUpdateEnable) { if (!ApkUpdate) { int ret = glupgrade.checkNetworkStatus(); if (ret == 1) { Debug.Log("WiFi OK!"); } else if (ret == 2) { Debug.Log("GPRS OK!"); //yield return new WaitForSeconds(10.0f); } else { sdUICharacter.Instance.ShowLoginMsg("APP更新:没有可使用的网络!3秒后重试。"); yield return(new WaitForSeconds(3.0f)); continue; } ApkUpdate = true; ret = glupgrade.InitUpgradeEx(3000); Debug.Log("InitUpgradeEx() return: " + ret); if (ret == 0) // 不需要升级 { Debug.Log("no app update"); break; } else if (ret == 1) // 强制升级 { //sdUICharacter.Instance.ShowLoginMsg("New Version Founded, Please Waiting..."); glupgrade.startUpdate(); } else if (ret == 2)// 非强制升级 { Debug.Log("No Force Update"); //break; } else if (ret == 3) { sdUICharacter.Instance.ShowLoginMsg("APP更新:内部错误(访问升级接口httpCode非200)"); ApkUpdate = false; } else if (ret == 4)// 非强制升级 { sdUICharacter.Instance.ShowLoginMsg("APP更新:内部错误(访问升级接口网络出错)"); ApkUpdate = false; } else if (ret == 5)// 非强制升级 { sdUICharacter.Instance.ShowLoginMsg("APP更新:内部错误(JSON格式转换出错)"); ApkUpdate = false; } else if (ret == 6)// 非强制升级 { sdUICharacter.Instance.ShowLoginMsg("APP更新:获取渠道打包信息失败!"); ApkUpdate = false; } else if (ret == 6)// 非强制升级 { sdUICharacter.Instance.ShowLoginMsg("APP更新:手机SD卡不可用!"); ApkUpdate = false; } else { break; } } yield return(new WaitForSeconds(5.0f)); } else { break; } } } if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(false); } #endif #if UNITY_IPHONE #endif sdUICharacter.Instance.HideLoginMsg(); if (Application.platform == RuntimePlatform.WindowsEditor) { } else { //读取分区信息.. Debug.Log("Read Server Area Information"); while (true) { string AreaID = BundleGlobal.AppVersion()["Area"]; Debug.Log("AreaID=" + AreaID); WWW w = new WWW("http://180.96.39.128:8004/arealist?areaid=" + AreaID); yield return(w); if (w.error == null) { JsonParse jp = new JsonParse(); jp.Parse(w.text); BundleGlobal.Instance.cdn = jp.cdnlist.ToArray(); //BundleGlobal.Instance. //jp.serverlist SDNetGlobal.m_lstSrvInfo = jp.serverlist; SDNetGlobal.serverNotice = jp.notice; SDNetGlobal.defaultServerID = jp.defaultServer; RefreshNotification(jp.Pushlist); break; } else { sdUICharacter.Instance.ShowLoginMsg("读取分区信息错误:" + w.error); } } GetSaveAreaInfo(); } sdUICharacter.Instance.HideLoginMsg(); //bbs if (SDNetGlobal.serverNotice.Length != 0) { sdUICharacter.Instance.ShowbbsWnd(true, SDNetGlobal.serverNotice, true, false); } //Update Bundle BundleGlobal.Instance.StartUpdateAllBundles(); if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(true); } while (BundleGlobal.Instance.updating) { if (m_slUpdateBar && BundleGlobal.Instance.needDownLoadNum > 0) { m_slUpdateBar.value = (float)BundleGlobal.Instance.downloadedNum / (float)BundleGlobal.Instance.needDownLoadNum; if (m_slUpdateBar.value > 0 && m_slUpdateBar.value < 0.022f) { m_slUpdateBar.value = 0.022f; } } if (m_lbUpdateInfo) { int Percent = BundleGlobal.Instance.GetBundlePercent(); if (Percent == 100) { Percent = 99; } string s = Percent + "%]["; if (Percent < 10) { s = "[0" + s; } else { s = "[" + s; } m_lbUpdateInfo.text = "更新资源..." + s + BundleGlobal.Instance.downloadedNum + "/" + BundleGlobal.Instance.needDownLoadNum + "]"; } yield return(0); } if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(false); } if (m_lbUpdateInfo) { m_lbUpdateInfo.text = "加载游戏配置文件..."; } //Load All Config File LoadLevelConfig(); while (m_strLevelConf == "" || m_strLevelLang == "" || m_strLevelMeta == "" || m_strLevelBox == "") { yield return(0); } sdLevelInfo.LoadLevelConfig(m_strLevelConf, m_strLevelLang, m_strLevelMeta, m_strLevelBox); sdResourceDependenceTable.GetSingleton().LoadMonsterTable("$Conf/MonsterDependence.xml", false); sdResourceDependenceTable.GetSingleton().LoadMonsterTable("$Conf/PetDependence.xml", false); sdAITable.GetSingleton().LoadAITable("$Conf/AITable.xml", false); sdConfDataMgr.Instance().Init(false); while (!sdConfDataMgr.Instance().isInitFinish()) { yield return(0); } sdUICharacter.Instance.HideLoginMsg(); //Init GHOME GPUSH if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { GHOME_CODE = -2; while (GHOME_CODE != 0) { if (GHOME_CODE == -2) { GHOME_CODE = -1; Debug.Log("InitGHome"); Init_GHOME_GPUSH(); } else { if (GHOME_CODE == 1) { Debug.Log("InitGHome Failed!"); GHOME_CODE = -2; } else { yield return(0); } } } GPUSH_API.Init("791000015", "9728werwerwc53ba8cded5a6a2227dd8"); sdUICharacter.Instance.HideLoginMsg(); } else { m_btEnterGameButton.SetActive(false); SDGlobal.StartGetMacAddress(); } if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { UILabel lb_srvName = m_btGameServer.transform.FindChild("Background").FindChild("Label").GetComponent <UILabel>(); lb_srvName.text = SDNetGlobal.serverName; } StartCoroutine(LoginProcess()); }
// Use this for initialization void Start() { // 初始化登录界面动画需要的变量. if (m_btEnterGameButton == null) { sdUICharacter.Instance.SelectSrvWnd = GameObject.Find("SelectServerWnd"); GameObject obj; m_btEnterGameButton = GameObject.Find("bt_StartGame"); if (m_btEnterGameButton) { m_btEnterGameButton.SetActive(false); } m_gHomeAccountButton = GameObject.Find("bt_Username"); if (m_gHomeAccountButton) { m_gHomeAccountButton.SetActive(false); } m_btGameServer = GameObject.Find("bt_Server"); if (m_btGameServer) { m_btGameServer.SetActive(false); } m_btPlayVideo = GameObject.Find("bt_PlayVideo"); if (m_btPlayVideo) { m_btPlayVideo.SetActive(false); } m_btSystemNotice = GameObject.Find("bt_systemnotice"); if (m_btSystemNotice != null) { m_btSystemNotice.SetActive(false); } string verison = BundleGlobal.AppVersion()["versionName"]; GameObject Label_Version = GameObject.Find("Label_Version"); if (Label_Version != null) { UILabel label = Label_Version.GetComponent <UILabel>(); if (label != null) { label.text = "Ver " + verison; } } m_userNameInput = GameObject.Find("Input"); if (m_userNameInput) { // PC环境下使用非G加账号.. if (Application.platform != RuntimePlatform.Android && Application.platform != RuntimePlatform.IPhonePlayer) { m_userNameInput.SetActive(true); FileStream file = null; try { file = new FileStream("Assets/account.txt", FileMode.Open); } catch (System.Exception e) { Debug.Log(e.Message); } if (file != null) { byte[] data = new byte[file.Length]; file.Read(data, 0, (int)file.Length); m_userNameInput.GetComponent <UIInput>().value = Encoding.UTF8.GetString(data); file.Close(); } } else { m_userNameInput.SetActive(false); } } obj = GameObject.Find("lb_UpdateBar"); if (obj) { m_lbUpdateInfo = obj.GetComponent <UILabel>(); } obj = GameObject.Find("pb_UpdateBar"); if (obj) { m_slUpdateBar = obj.GetComponent <UISlider>(); } if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(false); } obj = GameObject.Find("sp_fs0"); if (obj) { m_spFS0 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_fs1"); if (obj) { m_spFS1 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_zs0"); if (obj) { m_spZS0 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_zs1"); if (obj) { m_spZS1 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_zs2"); if (obj) { m_spZS2 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_ms0"); if (obj) { m_spMS0 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_ms1"); if (obj) { m_spMS1 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_ms2"); if (obj) { m_spMS2 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_yx0"); if (obj) { m_spYX0 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_yx1"); if (obj) { m_spYX1 = obj.GetComponent <UISprite>(); } obj = GameObject.Find("sp_yx2"); if (obj) { m_spYX2 = obj.GetComponent <UISprite>(); } } StartCoroutine(UpdateProcess()); }