private void CheckUserAgreement() { if (loginProxy.autoLogin) { this.LoginServerConnent(); return; } switch (GlobalData.sdkPlatform) { case SDKPlatform.ANDROID: if (loginView.toggle.isOn) { if (PlayerPrefs.HasKey(PrefsKey.USERMAC)) { this.SendLoginSucceed(); } else { AndroidSdkInterface.SendWeiXinLogin(); } } else { LoginFailDialog(); } break; case SDKPlatform.IOS: if (loginView.toggle.isOn) { if (PlayerPrefs.HasKey(PrefsKey.USERMAC)) { this.SendLoginSucceed(); } else { IOSSdkInterface.weChatLogin(); } } else { LoginFailDialog(); } break; case SDKPlatform.LOCAL: if (loginView.toggle.isOn) { SendLoginSucceed(); } else { LoginFailDialog(); } break; } }
//POST请求 IEnumerator POST() { string curVersion = ""; int customType = 2; if (Application.platform == RuntimePlatform.Android) { curVersion = AndroidSdkInterface.GetVersion(); customType = 2; } else if (Application.platform == RuntimePlatform.IPhonePlayer) { curVersion = IOSSdkInterface.GetVersion(); customType = 1; } else { curVersion = GlobalData.VERSIONS; } string url = string.Format("{0}?version={1}&type={2}", GlobalData.CheckVersionUrl, curVersion, customType); UnityWebRequest www = UnityWebRequest.Get(url); yield return(www.Send()); if (www.isError) { PopMsg.Instance.ShowMsg("获取版本失败:" + www.error); } else { JSONNode jsonData = JSON.Parse(www.downloadHandler.text); if (int.Parse(jsonData["success"].ToString()) == 0) { PopMsg.Instance.ShowMsg("获取版本失败:" + jsonData["message"].ToString()); } else { if (int.Parse(jsonData["is_update"].ToString()) == 1) { DialogMsgVO dialogMsgVO = new DialogMsgVO(); dialogMsgVO.dialogType = DialogType.CONFIRM; dialogMsgVO.content = string.Format("有新版本:{0}\n您是否要更新?", jsonData["version"].ToString()); dialogMsgVO.confirmCallBack = () => { if (GlobalData.sdkPlatform == SDKPlatform.ANDROID) { AndroidSdkInterface.DownloadFile(jsonData["filepath"].ToString()); } else if (GlobalData.sdkPlatform == SDKPlatform.IOS) { IOSSdkInterface.UpdateApp(GlobalData.ShareUrl); } }; DialogView dialogView = UIManager.Instance.ShowUI(UIViewID.DIALOG_VIEW) as DialogView; dialogView.data = dialogMsgVO; } } } }
/// <summary> /// 调用微信分享 /// </summary> private void OnShaderClick() { if (GlobalData.sdkPlatform == SDKPlatform.ANDROID) { string desc = "快来全民约牌吧"; AndroidSdkInterface.WeiXinShareScreen(desc, false); } else if (GlobalData.sdkPlatform == SDKPlatform.IOS) { UIManager.Instance.StartSaveScreen((Texture2D screenShot) => { byte[] screenJpg = screenShot.EncodeToJPG(); string jpgBase64 = Convert.ToBase64String(screenJpg); IOSSdkInterface.shareBitmap(jpgBase64, false); }); } }
/// <summary> /// 邀请好友 /// </summary> private void OnInviteClick() { var hallProxy = ApplicationFacade.Instance.RetrieveProxy(Proxys.HALL_PROXY) as HallProxy; string inviteUrl = string.Format("{0}?{1}={2}", GlobalData.ShareUrl, StartUpParam.ROOMID, hallProxy.HallInfo.roomCode); string title = string.Format("房间号:{0} 全民麻将", hallProxy.HallInfo.roomCode); string desc = string.Format("我在(全民约牌吧)开了{0}局,{1}风的4人房间,快来一起玩吧!", hallProxy.HallInfo.innings.GetHashCode(), hallProxy.HallInfo.gameRule == GameRule.WORD ? "有" : "无"); if (GlobalData.sdkPlatform == SDKPlatform.ANDROID) { AndroidSdkInterface.WeiXinShare(inviteUrl, title, desc, false); } else if (GlobalData.sdkPlatform == SDKPlatform.IOS) { IOSSdkInterface.shareWeChat(inviteUrl, title, desc, false); } }
public override void OnRegister() { base.OnRegister(); this.View.ButtonAddListening(this.View.CloseButton, () => { UIManager.Instance.HideUI(UIViewID.SHARE_VIEW); }); this.View.ButtonAddListening(this.View.FriendButton, () => { if (GlobalData.sdkPlatform == SDKPlatform.ANDROID) { string title = "江西景德镇翻精软四粒"; string desc = "快来翻精软四粒吧"; AndroidSdkInterface.WeiXinShare(GlobalData.ShareUrl, title, desc, false); } else if (GlobalData.sdkPlatform == SDKPlatform.IOS) { string title = "江西景德镇翻精软四粒"; string desc = "快来翻精软四粒吧"; IOSSdkInterface.WeiXinShare(GlobalData.ShareUrl, title, desc, false); } }); this.View.ButtonAddListening(this.View.CommunityButton, () => { if (GlobalData.sdkPlatform == SDKPlatform.ANDROID) { string title = "江西景德镇翻精软四粒"; string desc = "快来翻精软四粒吧"; AndroidSdkInterface.WeiXinShare(GlobalData.ShareUrl, title, desc, true); } else if (GlobalData.sdkPlatform == SDKPlatform.IOS) { string title = "江西景德镇翻精软四粒"; string desc = "快来翻精软四粒吧"; IOSSdkInterface.WeiXinShare(GlobalData.ShareUrl, title, desc, true); } }); }
/// <summary> /// 更新服务器时间 /// </summary> private void UpdateSystemTime() { if (battleProxy.isReport) {//战报显示战报发生时间 var reportDate = TimeHandle.Instance.GetDateTimeByTimestamp(battleProxy.report.startTime + (long)(Time.time - battleProxy.reportLocalTime) * 1000); // View.dateTxt.text = reportDate.ToString("yyyy-MM-dd"); View.timeTxt.text = reportDate.ToString("HH:mm"); } else { // View.dateTxt.text = gameMgrProxy.systemDateTime.ToString("yyyy-MM-dd"); View.timeTxt.text = gameMgrProxy.systemDateTime.ToString("HH:mm"); } if (Application.platform == RuntimePlatform.Android) { View.Battery.value = (float)AndroidSdkInterface.GetElectricity() / 100f; } else if (Application.platform == RuntimePlatform.IPhonePlayer) { View.Battery.value = (float)IOSSdkInterface.GetElectricity() / 100f; } if (Application.internetReachability == UnityEngine.NetworkReachability.NotReachable) { View.netIcon.sprite = Resources.Load <Sprite>("Textures/NetPoor"); } else if (gameMgrProxy.pingBackMS < 100) { View.netIcon.sprite = Resources.Load <Sprite>("Textures/NetPerfect"); } else if (gameMgrProxy.pingBackMS < 200) { View.netIcon.sprite = Resources.Load <Sprite>("Textures/NetGood"); } else { View.netIcon.sprite = Resources.Load <Sprite>("Textures/NetOK"); } }
/// <summary> /// 获取商品信息返回 /// </summary> /// <param name="bytes"></param> //private void GetProductionHandler(byte[] bytes) //{ // var getProductListS2C = NetMgr.Instance.DeSerializes<GetProductListS2C>(bytes); // productList = getProductListS2C.productInfo; // SendNotification(NotificationConstant.MEDI_HALL_PRODUCTUPDATE); //} /// <summary> /// 获取订单信息返回 /// </summary> /// <param name="bytes"></param> private void GetOrderInfoHandler(byte[] bytes) { var getOrderInfoS2C = NetMgr.Instance.DeSerializes <GetOrderInfoS2C>(bytes); PayVO payVO = new PayVO(); payVO.money = (getOrderInfoS2C.amount * 100).ToString(); payVO.subject = getOrderInfoS2C.goodsName; payVO.pricePointDec = getOrderInfoS2C.goodsName; payVO.outTradeNo = getOrderInfoS2C.payid; Debug.Log(JsonUtility.ToJson(payVO)); if (GlobalData.sdkPlatform == SDKPlatform.ANDROID) { AndroidSdkInterface.FWPay(JsonUtility.ToJson(payVO)); } else if (GlobalData.sdkPlatform == SDKPlatform.IOS) { IOSSdkInterface.otherPay(JsonUtility.ToJson(payVO)); orderTimeId = Timer.Instance.AddTimer(5, 24, 5, () => { NetMgr.Instance.SendBuff <GetUserInfoC2S>(SocketType.HALL, MsgNoC2S.C2S_Hall_GET_USERINFO.GetHashCode(), 0, new GetUserInfoC2S(), true); }); } }