/// <summary> /// 断线重连 /// </summary> IEnumerator Reconnect() { lastHeartTime = Time.realtimeSinceStartup; LoadingNode.OpenLoadingNode(LoadingType.Common); Close(); reconnectTime++; bool isSuccess = false; isSuccess = Init(); if (!isSuccess) { if (reconnectTime < 3) { yield return(new WaitForSecondsRealtime(5)); StartCoroutine(Reconnect()); } else { OpenTipNetError(); } } else { reconnectTime = 0; LoadingNode.instance.Close(); //重新登录 } }
/// <summary> /// 解析收到的消息 /// </summary> IEnumerator AnalysisMessage() { WaitForSecondsRealtime wfsrAnalysisWait = new WaitForSecondsRealtime(0.005f); while (true) { Message message = null; lock (allPackages) { if (allPackages.Count > 0) { message = allPackages.Dequeue(); UIUtils.Log("收到消息:" + message.messageId.ToString()); } } if (message != null) { LoadingNode.CloseLoadingNode(); #region ...消息处理 switch (message.messageId) { default: UIUtils.Log("未处理的消息id :" + message.messageId); break; } #endregion } yield return(wfsrAnalysisWait); } }
public IEnumerator DownApk(string url) { WWW www = new WWW(url); do { yield return(null); LoadingNode.OpenLoadingNode(LoadingType.Progress, "正在下载最新资源包...", www.progress); } while (!www.isDone); if (www.size > 0) { string filePath = Application.persistentDataPath + "/APK"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } File.WriteAllBytes(filePath + "/version.apk", www.bytes); SDKManager.Instance.Install(filePath + "/version.apk"); } else { SetTimeout.add(2f, () => { LoadingNode.CloseLoadingNode(); }); } }
/// <summary> /// 打开一个LoadingNode /// </summary> /// <param name="type">Loading类型</param> /// <param name="describe">描述</param> /// <param name="progress">加载进度</param> public static void OpenLoadingNode(LoadingType type, string describe = null, float progress = 0, long fileAllLength = 0) { instance = NodeManager.OpenFloatNode <LoadingNode>(); if (instance.transform.parent != PageManager.Instance.transform) { NodeManager.DontDestroyAtChangePage(instance); } switch (type) { case LoadingType.Common: instance.commonLoadingPnl.SetActive(true); instance.downLoadingPnl.SetActive(false); break; case LoadingType.Progress: instance.commonLoadingPnl.SetActive(false); instance.downLoadingPnl.SetActive(true); instance.downLoadingProgressRtf.sizeDelta = new Vector2(downLoadingWidth * progress, downLoadingHeight); string allLength = MiscUtils.GetMillionFromByte(fileAllLength).ToString("F2"); string currlength = MiscUtils.GetMillionFromByte((long)(fileAllLength * progress)).ToString("F2"); instance.progressTxt.text = "<color=#8CF976FF>" + currlength + "MB</color>/<color=#FEE646FF>" + allLength + "MB</color>"; break; } if (!string.IsNullOrEmpty(describe)) { instance.describe.text = describe; } else { instance.describe.text = defaultLoadingDes; } }
/// <summary> /// 添加数据到发送队列 /// </summary> /// <param name="c2g">消息主体</param> /// <param name="isPrevent">是否显示loading</param> public void AddSendMessageQueue(C2GMessage c2g, bool isPrevent = false) { if (!PageManager.Instance.isCanSend) { return; } if (isPrevent && mSocket.Connected) { LoadingNode.OpenLoadingNode(LoadingType.Common); } c2g.testLogicId = testLogicId; byte[] bytes = BuildPackage(c2g); if (sendList.Count > 0) { if (!sendList.Contains(bytes)) { sendList.Add(bytes); } else { UIUtils.Log("消息重复"); } } else { sendList.Add(bytes); } if (c2g.msgid != MessageId.C2G_HeartBeat) { UIUtils.Log("发送消息:" + c2g.msgid.ToString()); } }
public void InstallAPK(string file) { LoadingNode.OpenLoadingNode(LoadingType.Progress, "正在安装新版本中..."); AndroidJavaObject jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity"); jo.Call("installApk", file); }
/// <summary> /// 版本/文件更新 /// </summary> /// <returns></returns> IEnumerator VersionUpdate() { WWW www = new WWW(ConstantUtils.bundleTipsUrl); yield return(www); if (string.IsNullOrEmpty(www.error)) { List <BundleManager.BundleInfo> bmbis = new List <BundleManager.BundleInfo>(); JsonData jds = JsonMapper.ToObject(www.text); string md5, file, path; int length; for (int i = 0; i < jds["files"].Count; i++) { JsonData jd = jds["files"][i]; file = jd.TryGetString("file"); path = ConstantUtils.AssetBundleFolderPath + file; md5 = MiscUtils.GetMD5HashFromFile(path); if (string.IsNullOrEmpty(md5) || md5 != jd.TryGetString("md5")) { bmbis.Add(new BundleManager.BundleInfo() { _url = ConstantUtils.bundleDownLoadUrl + file, _path = path, }); length = int.Parse(jd.TryGetString("fileLength")); allFilesLength += length; } } if (bmbis.Count > 0) { StartCoroutine(BundleManager.Instance.DownloadBundleFiles(bmbis, (progress) => { LoadingNode.OpenLoadingNode(LoadingType.Progress, "自动更新中...", progress, allFilesLength); }, (isFinish) => { if (isFinish) { StartCoroutine(VersionUpdateFinish()); } else { TipManager.Instance.OpenTip(TipType.SimpleTip, "部分文件更新失败,正在准备重试..."); StartCoroutine(VersionUpdate()); } })); } else { StartCoroutine(VersionUpdateFinish()); } } else { UIUtils.Log(www.error); LoadingNode.CloseLoadingNode(); } }
public override void Init() { base.Init(); logo.GetComponent <CommonAnimation>().alphaEndAction = () => { LoadingNode.OpenLoadingNode(LoadingType.Progress); StartCoroutine(VersionUpdate()); }; }
IEnumerator ScanQRcode() { string result = QRCode.DecodeColData(webCameraTexture.GetPixels32(), webCameraTexture.width, webCameraTexture.height); scaning += "."; if (scaning == "扫描中....") { scaning = "扫描中"; } txt.text = scaning; if (result != "") { webCameraTexture.Stop(); isScanner = false; txt.text = "扫描成功"; LoadingNode.OpenLoadingNode(LoadingType.Common); try { JsonData jd = JsonMapper.ToObject(result); switch (jd.TryGetString("id")) { case "1": SocialModel.Instance.AddFriend(int.Parse(jd.TryGetString("content"))); TipManager.Instance.OpenTip(TipType.SimpleTip, "发送成功,等待通过", 1f); break; case "2": SocketClient.Instance.AddSendMessageQueue(new C2GMessage { msgid = MessageId.C2G_QueryTableInfo, queryTableInfo = new QueryTableInfo() { tableId = jd.TryGetString("content") } }); break; case "3": Application.OpenURL(jd.TryGetString("content")); break; default: break; } } catch (System.Exception) { TipManager.Instance.OpenTip(TipType.SimpleTip, "未识别的二维码"); } PageManager.Instance.OpenLastPage(); } yield return(new WaitForEndOfFrame()); }
/// <summary> /// 更新结束后执行的函数 /// </summary> IEnumerator VersionUpdateFinish() { #if !UNITY_EDITOR string luaScript = BundleManager.Instance.GetLuaScript(); if (!string.IsNullOrEmpty(luaScript)) { luaenv.DoString(luaScript); } #endif LoadingNode.OpenLoadingNode(LoadingType.Progress, null, 1); yield return(ConstantUtils.frameWait); LoadNecessaryBundle(); MiscUtils.StartGPS(); PageManager.Instance.OpenPage <TestPage>(); }
/// <summary> /// 断线重连 /// </summary> IEnumerator Reconnect(bool isReLogin = true) { lastHeartTime = Time.realtimeSinceStartup; //TODO 显示重连状态 LoadingNode.OpenLoadingNode(LoadingType.Common); Close(); reconnectTime++; bool isSuccess = false; isSuccess = Init(); if (!isSuccess) { if (reconnectTime < 3) { yield return(new WaitForSecondsRealtime(5)); StartCoroutine(Reconnect()); } else { OpenTipNetError(); } } else { reconnectTime = 0; //重新登录 if (isReLogin) { AddSendMessageQueue(new C2GMessage() { msgid = MessageId.C2G_Login, login = new Login() { token = LoginPage.token } }, true); sendList.Add(sendList[0]); if (sendList.Count > 1) { sendList.RemoveAt(0); } } LoadingNode.instance.Close(); } }
public void CheckVersion(CallBack onVersionUpdateFinish) { _onVersionUpdateFinish = onVersionUpdateFinish; LoadingNode.OpenLoadingNode(LoadingType.Progress, "正在检测是否有新版本...", 0); #if UNITY_EDITOR LoadingNode.OpenLoadingNode(LoadingType.Progress, "正在检测是否有新版本...", 1); SetTimeout.add(1, () => { LoadingNode.CloseLoadingNode(); if (_onVersionUpdateFinish != null) { _onVersionUpdateFinish(); _onVersionUpdateFinish = null; } }); //StartCoroutine(BigVersionUpdate(true)); #elif UNITY_ANDROID StartCoroutine(BigVersionUpdate(true)); #elif UNITY_IPHONE onVersionUpdateFinish(); //StartCoroutine(BigVersionUpdate()); #endif }
/// <summary> /// 添加数据到发送队列 /// </summary> /// <param name="c2s">消息主体</param> /// <param name="isPrevent">是否显示loading</param> public void AddSendMessageQueue(Message c2s, bool isPrevent = false) { if (isPrevent && mSocket.Connected) { LoadingNode.OpenLoadingNode(LoadingType.Common); } byte[] bytes = BuildPackage(c2s); if (!tempSendList.Contains(bytes)) { lock (tempSendList) tempSendList.Add(bytes); } else { UIUtils.Log("消息重复"); } if (c2s.messageId != MessageId.Heart) { UIUtils.Log("发送消息:" + c2s.messageId.ToString()); } }
/// <summary> /// 尝试token登录 /// </summary> /// <returns></returns> public static IEnumerator TryTokenLogin() { yield return(new WaitForEndOfFrame()); if (!TokenExist()) { if (token != null) { SocketClient.Instance.AddSendMessageQueue(new C2GMessage { login = new Login() { token = token }, msgid = MessageId.C2G_Login }, true); } } else { LoadingNode.CloseLoadingNode(); } }
/// <summary> /// 打开一个LoadingNode /// </summary> /// <param name="type">Loading类型</param> /// <param name="describe">描述</param> /// <param name="progress">加载进度</param> public static void OpenLoadingNode(LoadingType type, string describe = null, float progress = 0) { if (instance == null) { instance = NodeManager.OpenNode <LoadingNode>(null, null, false, false); } switch (type) { case LoadingType.Common: instance.progress.gameObject.SetActive(false); instance.StartCoroutine(instance.SetTimer()); break; case LoadingType.Progress: instance.progress.gameObject.SetActive(true); instance.progress.text = (progress * 100).ToString("F1"); break; } if (!string.IsNullOrEmpty(describe)) { instance.describe.text = describe; } }
public IEnumerator BigVersionUpdate(bool isTip) { WWW www = new WWW(ConstantUtils.urlVersionConfigPath); yield return(www); if (string.IsNullOrEmpty(www.error)) { JsonData jds = JsonMapper.ToObject(www.text.Trim()); string apkUrl = ""; #if UNITY_ANDROID serverVersion = jds["android_severVersion"].ToString(); apkUrl = jds["android_apkUrl"].ToString(); UserInfoModel.userInfo.downUrl = jds["android_webDownApkUrl"].ToString(); #elif UNITY_IPHONE serverVersion = jds["ios_curVersion"].ToString(); apkUrl = jds["ios_apkUrl"].ToString(); UserInfoModel.userInfo.downUrl = jds["ios_webDownApkUrl"].ToString(); #elif UNITY_EDITOR serverVersion = jds["android_curVersion"].ToString(); apkUrl = jds["android_apkUrl"].ToString(); UserInfoModel.userInfo.downUrl = jds["android_webDownApkUrl"].ToString(); #endif if (VersionManager.Instance.MastUpdate()) { CallBack call = () => { #if UNITY_ANDROID StartCoroutine(DownloadAPK(apkUrl)); #elif UNITY_IPHONE Application.OpenURL(apkUrl); //IOSCall.Instance.OpenUrl (url); #endif }; if (isTip) { TipManager.Instance.OpenTip(TipType.AlertTip, "检测到版本有更新,请更新!", 0, () => { call(); }); } else { call(); } } else {//如果不需要更新 if (File.Exists(Application.persistentDataPath + "/APK" + "/version.apk")) { File.Delete(Application.persistentDataPath + "/APK" + "/version.apk"); } SetTimeout.add(2f, () => { LoadingNode.CloseLoadingNode(); }); } } }
IEnumerator OpenTipAc(TipType tipType, string describe, float waitTime, UnityAction sureAction, UnityAction cancelAction) { Instance.gameObject.transform.SetAsLastSibling(); Transform tf = GetTip(tipType); if (tf) { tf.Find("Describe").GetComponent <Text>().text = describe; if (tipType != TipType.SimpleTip) { UIUtils.RegisterButton("BtnSure", () => { ButtonCallBack(tf.gameObject, sureAction); }, tf); UIUtils.RegisterButton("BtnClose", () => { tf.gameObject.SetActive(false); }, tf); if (tipType == TipType.ChooseTip) { UIUtils.RegisterButton("BtnCancel", () => { ButtonCallBack(tf.gameObject, cancelAction); }, tf); } } else { if (waitTime == 0) { waitTime = 3; } UIUtils.RegisterButton("Background", () => { Destroy(tf.gameObject); }, tf); } tf.gameObject.SetActive(true); SetCanvasRarcaster(); LoadingNode.CloseLoadingNode(); Transform timerTf = tf.Find("Timer"); if (waitTime != 0) { if (timerTf) { Timer timer = timerTf.GetComponent <Timer>(); timer.allLength = waitTime; timer.ResetTimer(true); } bool isSimpleTip = tipType.Equals(TipType.SimpleTip); yield return(new WaitForSecondsRealtime(waitTime)); if (tf && tf.gameObject.activeSelf) { if (isSimpleTip) { Destroy(tf.gameObject); } else { tf.gameObject.SetActive(false); } if (cancelAction != null) { cancelAction(); } } } else if (timerTf) { timerTf.gameObject.SetActive(false); } } }
/// <summary> /// 解析收到的消息 /// </summary> IEnumerator AnalysisMessage() { while (true) { if (allPackages.Count > 0) { G2CMessage message = allPackages.Dequeue(); MessageId messageId = message.msgid; if (messageId != MessageId.G2C_HeartBeatResp && messageId != MessageId.G2C_SystemNotice) { LoadingNode.CloseLoadingNode(); UIUtils.Log("收到消息:" + messageId.ToString() + ",result::" + message.result); } if (message.result == 1) { #region ...消息处理 switch (messageId) { #region ...登录注册相关 case MessageId.G2C_Kick_ReLogin: LoginPage.TakeLogin(); break; case MessageId.G2C_Kick: TipManager.Instance.OpenTip(TipType.ChooseTip, "您被踢出登录是否重登?", 0, () => { PageManager.Instance.OpenPage <LoginPage>(); }); break; case MessageId.G2C_LoginResp: UserInfoModel.userInfo.inDzz = message.loginresp.inDdz; UserInfoModel.userInfo.release = message.loginresp.vno; LoginPage.LoginResult(message.loginresp.token); print("是否在斗地主:" + message.loginresp.inDdz); break; case MessageId.G2C_UserFlushData: UserInfoModel.userInfo.InitUserData(message.flushdata); break; case MessageId.G2C_UserSysNotice: //message.UserSysNotice.msg break; #endregion #region 大厅相关 case MessageId.G2C_QueryAmountOfPlayerInGameResp: var mainPage = PageManager.Instance.GetPage <MainPage>(); if (mainPage) { mainPage.SetOnlineNum(message.queryAmountOfPlayerInGameResp); } break; case MessageId.G2C_QueryUserMsgResp: MessageModel.Instance.QueryUserMsgFinish(message.UserMsg); break; case MessageId.G2C_ReadUserMsgResp: NodeManager.GetNode <MessageNode>().ReadMsg(message.ReadMsgResp); break; case MessageId.G2C_QueryGoodsResp: NodeManager.GetNode <BagNode>().goodsPanel.SetData(message.QueryGoodsResp.goods); break; case MessageId.G2C_UseGoodsResp: NodeManager.GetNode <BagNode>().goodsPanel.cashPanel.OnClickTrueFinish(message.UseGoodsResult.result); break; case MessageId.G2C_SaleUserGoodsResp: NodeManager.GetNode <BagNode>().goodsPanel.salePanel.OnClickTrueFinish(message.SaleUserGoodsResp.result); break; case MessageId.G2C_QueryTickRecordResp: NodeManager.GetNode <BagNode>().redeemPanel.QueryTickFinish(message.QueryTickRecordResp); break; case MessageId.G2C_UpdateUserSafeBoxResp: NodeManager.GetNode <SafeBoxNode>().OnClickTrueFinish(message.UpdateUserSafeBoxResp.result); break; case MessageId.G2C_BuyGoodsInStoreResp: //购买物品 StoreNode.ShowRechargeResult(message.BuyGoodsInStoreResp); break; case MessageId.G2C_ChargeNotic: //sdk购买回调 StoreNode.ChargeNoticFinish(message.ChargeNotice); break; case MessageId.G2C_QueryRankResp: RankNode.QueryRankFinish(message.queryRankResp); break; case MessageId.G2C_UpdateUser: TipManager.Instance.OpenTip(TipType.SimpleTip, "操作成功"); break; case MessageId.G2C_IsVipUserResp: UserInfoNode.FinishVipDay(message.IsVipUserResp); BqPanel.FinishVipDay(message.IsVipUserResp); break; case MessageId.G2C_QueryTableInfoResp: //请求房间信息 JoinGameRoonNode.G2C_EnterSuccess(message.queryTableInfoResp); break; case MessageId.G2C_YuePaiTableResp: if (MaJangPage.Instance) { int finalIndex = message.yuePaiTableResp.yuePaiTable.Count - 1; GameLogNode.G2C_Load(message.yuePaiTableResp.yuePaiTable[finalIndex]); } else if (PageManager.Instance.CurrentPage is LandlordsPage) { int finalIndex = message.yuePaiTableResp.yuePaiTable.Count - 1; CardResultShowNode cardResultNode = NodeManager.GetNode <CardResultShowNode>(); if (cardResultNode) { cardResultNode.Inits(message.yuePaiTableResp.yuePaiTable[finalIndex]); } else { GameLogNode.G2C_Load(message.yuePaiTableResp.yuePaiTable[finalIndex]); } } else if (PageManager.Instance.CurrentPage is MainPage) { YuepaiLogNode.G2C_ReceiveLog(message.yuePaiTableResp); } break; case MessageId.G2C_UnifiedOrder: SDKManager.Instance.SendWechatPay(message.UnifiedOrderResp); break; case MessageId.G2C_AliOrder: SDKManager.Instance.SendAliPay(message.AliOrderResp); break; case MessageId.G2C_QueryGameRoomResp: SelectRoomPage.Instance.QueryGameRoomFinish(message.queryGameRoomResp); break; case MessageId.G2C_SystemNotice: //系统消息 for (int i = 0; i < message.SystemNotice.notice.Count; i++) { NoticeNode.Add(message.SystemNotice.notice[i]); } break; #region 好友相关 case MessageId.G2C_QueryFriendResp: //好友列表 SocialNode node = NodeManager.GetNode <SocialNode>(); if (node) { node.friendRankPanel.G2C_FriendRank(message.queryFriendResp.friendInfo); } else { InvateNode.G2C_OnLineFriend(message.queryFriendResp.friendInfo); } break; case MessageId.G2C_QueryRenshiResp: //认识的人 KnowPanelPanel.G2C_Know(message.queryRenshiResp.friendInfo); break; case MessageId.G2C_QueryNearbyResp: //附近的人 NearPanel.G2C_Near(message.queryNearbyResp.friendInfo); break; case MessageId.G2C_SharePositionResp: //位置分享 TipManager.Instance.OpenTip(TipType.SimpleTip, "分享位置信息成功!"); //请求附近的人 AddSendMessageQueue(new C2GMessage() { msgid = MessageId.C2G_QueryNearbyReq }); break; case MessageId.G2C_ApplyFriendNotice: //有人加我好友 NodeManager.OpenNode <AddFriendTipNode>(null, null, false, false).Inits(message.applyFriendNotice.friendInfo); SocialNode socialsNode = NodeManager.GetNode <SocialNode>(); if (socialsNode) { socialsNode.messagePanel.G2C_AddFriends(new List <FriendInfo>() { message.applyFriendNotice.friendInfo }); } break; case MessageId.G2C_ApplyFriendResp: //加好友结果 TipManager.Instance.OpenTip(TipType.SimpleTip, "发送成功,等待验证"); break; case MessageId.G2C_ReplyFriendNotice: if (message.replyFriendNotice.friendInfo.userId == UserInfoModel.userInfo.userId) { break; } string tipStr = ""; switch (message.replyFriendNotice.friendInfo.relation) { case -1: tipStr = message.replyFriendNotice.friendInfo.nickname + " 已拒绝您的好友申请"; break; case 1: FriendRankPanel.Inits(); tipStr = message.replyFriendNotice.friendInfo.nickname + " 已同意您的好友申请"; break; } TipManager.Instance.OpenTip(TipType.SimpleTip, tipStr); RankNode ranknode = NodeManager.GetNode <RankNode>(); if (ranknode) { ranknode.playinfoPanel.QueryRelation(message.replyFriendNotice.friendInfo.userId); } break; case MessageId.G2C_ReplyFriendResp: FriendRankPanel.Inits(); break; case MessageId.G2C_FindFriendResp: //查找好友 FindFriendPanel.G2C_Find(message.findFriendResp); break; case MessageId.G2C_FriendChatResp: //收到好友聊天 SocialModel.Instance.ReceiveMessage(message.friendChatResp); SocialModel.Instance.isHaveNewMessage = true; if (PageManager.Instance.CurrentPage is MainPage) { PageManager.Instance.GetPage <MainPage>().SetFriendRed(); } else if (PageManager.Instance.CurrentPage is SelectRoomPage) { PageManager.Instance.GetPage <SelectRoomPage>().bottomPanel.SetFriendRedPoint(); } break; case MessageId.G2C_GiveSilver: //赠送成功 TipManager.Instance.OpenTip(TipType.SimpleTip, "赠送成功!"); break; case MessageId.G2C_QueryFriendOfflineChatResp: SocialNode social_node = NodeManager.GetNode <SocialNode>(); if (social_node) { social_node.messagePanel.G2C_RecentContacts(message.queryFriendOfflineChatResp.friendOfflineChat); } break; case MessageId.G2C_QueryRelationResp: GameRoleInfoNode gameRole_node = NodeManager.GetNode <GameRoleInfoNode>(); if (gameRole_node) { gameRole_node.SetFriend(message.queryRelationResp.relation); } RankNode rankNode = NodeManager.GetNode <RankNode>(); if (rankNode) { rankNode.playinfoPanel.QueryRelationFinish(message.queryRelationResp.relation); } MatchReadyNode matchReadyNode = NodeManager.GetNode <MatchReadyNode>(); if (matchReadyNode) { matchReadyNode.chatPanel.CurItem.QueryRelationFinish(message.queryRelationResp.relation); } break; case MessageId.G2C_QueryApplicantsResp: SocialNode socialNode = NodeManager.GetNode <SocialNode>(); if (socialNode) { socialNode.messagePanel.G2C_AddFriends(message.queryApplicantsResp.friendInfo); } break; case MessageId.G2C_RemoveFriendResp: TipManager.Instance.OpenTip(TipType.SimpleTip, "删除成功!"); FriendRankPanel.Inits(); break; #endregion #region 意见反馈 case MessageId.G2C_QueryOpinionResp: //我的历史反馈 FeedbackNode feed_node = NodeManager.GetNode <FeedbackNode>(); if (feed_node != null) { feed_node.G2C_LoadItems(message.queryOpinionResp.opinion); } break; case MessageId.G2C_SubmitOpinionResp: TipManager.Instance.OpenTip(TipType.SimpleTip, "提交成功"); FeedbackNode.G2C_Submit(); break; #endregion #region 任务 case MessageId.G2C_DaliyTask: //每日任务列表 TaskNode.TaskRefresh(message.DailyTaskResp.dailyTask); break; case MessageId.G2C_CashingPrize: //领奖 TaskNode.Reward(message.CashingPrizeResp.awardCount); break; case MessageId.G2C_Complete1Task: //完成任务 TaskNode.ReqTasks(); break; #endregion #endregion #region 比赛 case MessageId.G2C_LoadMatcherResp: MatchModel.Instance.LoadMatcherFinish(message.loadMatcherResp); break; case MessageId.G2C_JoinMatcherResp: MatchApplyNode.JoinMatcherFinish(message.JoinMatcherResp); break; case MessageId.G2C_PrepareMatcherResp: MatchModel.Instance.PrepareMatcherFinish(message.prepareMatcherResp); break; case MessageId.G2C_QuitMatcherResp: var readyNode = NodeManager.GetNode <MatchReadyNode>(); if (readyNode) { readyNode.QuitMatcher(); } var waitNode = NodeManager.GetNode <MatchWaitNode>(); if (waitNode) { waitNode.QuitMatcher(); } break; case MessageId.G2C_MatcherRiseSuccess: var waitNode2 = NodeManager.GetNode <MatchWaitNode>(); if (waitNode2) { waitNode2.MatcherRise(message.waitMatcherRiseResp); } break; case MessageId.G2C_StartMatcher: MatchReadyNode.StartMatch(); break; case MessageId.G2C_MatcherCountResp: MatchModel.Instance.MatcherCountFinish(message.matcherCountResp); break; case MessageId.G2C_UserMatcherRewardResp: MatchModel.Instance.UserMatcherRewardFinish(message.userMatcherRewardResp); break; case MessageId.G2C_MatcherHistoryResp: MatchModel.Instance.MatcherHistoryFinish(message.matcherHistoryResp); break; case MessageId.G2C_UserMatcherFriendRankResp: MatchModel.Instance.MatcherFriendRankFinish(message.userMatcherFriendRankResp); break; case MessageId.G2C_MatcherChatResp: MatchReadyNode.MatcherChat(message.matcherChatResp); break; case MessageId.G2C_MatcherJoinCount: MatchReadyNode.JoinCountFlush(message.matcherJoinCount); break; case MessageId.G2C_WaitMatcherRiseResp: MatchWaitNode.OpenMatchWait(message.waitMatcherRiseResp); break; case MessageId.G2C_MatcherPlayerRankingResp: //比赛排行 MatchRankRewardNode.QueryRankFinish(message.matcherPlayerRankingResp); MatchWaitRankRewardPanel.QueryRankFinish(message.matcherPlayerRankingResp); break; case MessageId.G2C_DieMatcherPlayerResp: NodeManager.OpenNode <MatchResultNode>("match", null, true, false).DieMatcherFinish(message.dieMatcherPlayerResp); break; case MessageId.G2C_MedalResp: NodeManager.OpenNode <MatchResultNode>("match", null, true, false).MedalFinish(message.medalResp); break; case MessageId.G2C_CurrentMatcherInfoResp: //收到比赛消息 MatchRulesNode.DisplayMatchInfo(message.currentMatcherInfoResp); //LandlordsNet.BisaiInfoResp(message.currentMatcherInfoResp); break; case MessageId.G2C_MyMatcherRankingResp: //收到我的排行信息 if (PageManager.Instance.GetPage <LandlordsPage>()) { LandlordsNet.BisaiMyRankInfoResp(message.myMatcherRankingResp); } else if (PageManager.Instance.GetPage <MaJangPage>()) { MaJangPage.Instance.RefreshMatchInfo(message.myMatcherRankingResp); } break; case MessageId.G2C_MatcherFriendResp: MatchReadyNode.InviteFriend(message.matcherFriendResp); break; case MessageId.G2C_InviteFriendMatcherResp: var inviteResp = message.inviteFriendMatcherResp; if (inviteResp.code == 1) { TipManager.Instance.OpenTip(TipType.SimpleTip, "已发送邀请"); } else if (inviteResp.code == 2) { TipManager.Instance.OpenTip( TipType.ChooseTip, "您的好友 " + inviteResp.hostName + " 邀请您参加" + inviteResp.matcherName, 10f, delegate { MatchModel.Instance.JoinMatch((int)inviteResp.cost, inviteResp.costType, inviteResp.matcherId, inviteResp.matcherName); MatcherInfo cur = new MatcherInfo() { matchId = inviteResp.matcherId }; MatchModel.Instance.CurData = cur; } ); } break; case MessageId.G2C_InviteFriendYuePaiResp: if (message.inviteFriendYuePaiResp.code == 3) { TipManager.Instance.OpenTip(TipType.SimpleTip, "对方已拒绝您的邀请"); } break; case MessageId.G2C_MatcherTickUser: if (NodeManager.GetNode <MatchReadyNode>()) { NodeManager.CloseTargetNode <MatchReadyNode>(); MatchModel.Instance.CurData = null; TipManager.Instance.OpenTip(TipType.SimpleTip, "人数不符合比赛要求,请重新报名"); } break; #endregion #region ...麻将相关 case MessageId.G2C_CreateTableResp: PageManager.Instance.OpenPage <MaJangPage>(); break; case MessageId.G2C_GameJoinTableResp: case MessageId.G2C_MjChangeTableResp: if (!PageManager.Instance.GetPage <MaJangPage>()) { PageManager.Instance.OpenPage <MaJangPage>(); } MaJangPage.Instance.JoinRoomResult(message.GameJoinTableResp.user, message.GameJoinTableResp.detail, message.GameJoinTableResp.isChangeTable); break; case MessageId.G2C_GameJoinTableNotice: if (MaJangPage.Instance) { MaJangPage.Instance.OtherJoinRoomResult(message.GameJoinTableNotice.user); } break; case MessageId.G2C_GameLeaveTableResp: if (MaJangPage.Instance) { MaJangPage.Instance.LeaveByPos(message.GameLeaveTableResp.pos, false); } break; case MessageId.G2C_GamePrepareNotice: if (MaJangPage.Instance) { MaJangPage.Instance.Ready(message.GamePrepareNotice.pos, message.GamePrepareNotice.prepared); } break; case MessageId.G2C_GameStartResp: if (message.GameStartResp.isReconnect) { PageManager.Instance.OpenPage <MaJangPage>(); } MaJangPage.Instance.StartOrReConnectGame(message.GameStartResp); if (message.GameStartResp.isReconnect && message.GameStartResp.state != 4) { canHandleMessage = false; //重连完成前,禁止处理所有消息 } break; case MessageId.G2C_UserStepOverNotice: if (MaJangPage.Instance) { MaJangPage.Instance.StartOutMj(message.UserStepOverNotice); } break; case MessageId.G2C_UserGetMjResp: if (MaJangPage.Instance) { MaJangPage.Instance.GetUserGetMj(message.UserGetMjResp); } break; case MessageId.G2C_UserActionNotice: if (MaJangPage.Instance) { MaJangPage.Instance.GetUserAction(message.UserActionNotice); } break; case MessageId.G2C_UserMjActionResp: if (MaJangPage.Instance) { MaJangPage.Instance.currentPlayer.ExecuteAction(message.UserActionResp); } break; case MessageId.G2C_ChangeBaoPaiNotice: if (MaJangPage.Instance) { MaJangPage.Instance.OpenBao(message.changeBaoPaiNotice); } break; case MessageId.G2C_MjResult: if (MaJangPage.Instance) { if (message.MjResult.isFinal) { MaJangPage.Instance.GameResult(message.MjResult); canHandleMessage = false; //弹出当前局结算后,禁止处理所有消息 } else { MaJangPage.Instance.Xjxd(message.MjResult); } } break; case MessageId.G2C_MjChangePosResp: if (MaJangPage.Instance) { MaJangPage.Instance.ChangeSeatResult(message.mjChangePosResp); } break; case MessageId.G2C_MjChangePosApplyResp: if (MaJangPage.Instance) { MaJangPage.Instance.ChangeSeatReply(message.mjChangePosApplyResp); } break; case MessageId.G2C_MjChangePosNotice: if (MaJangPage.Instance) { MaJangPage.Instance.OtherPlayerChangeSeat(message.mjChangePosNotice.pos1, message.mjChangePosNotice.pos2); } break; case MessageId.G2C_MjTuoguanResp: if (MaJangPage.Instance) { MaJangPage.Instance.TrusteeshipResult(true); } break; case MessageId.G2C_MjCancelTuoguanResp: if (MaJangPage.Instance) { MaJangPage.Instance.TrusteeshipResult(false); } break; case MessageId.G2C_MjTuoguanNotice: if (MaJangPage.Instance) { MaJangPage.Instance.TrusteeshipResult(true, message.mjTuoguanNotice.pos); } break; case MessageId.G2C_MjCancelTuoguanNotice: if (MaJangPage.Instance) { MaJangPage.Instance.TrusteeshipResult(false, message.mjCancelTuoguanNotice.pos); } break; case MessageId.G2C_UserStateChangeNotice: if (MaJangPage.Instance) { MaJangPage.Instance.SetPlayerStatu(message.UserStateChangeNotice); } break; case MessageId.G2C_DisbandChooiseNotice: JiesanNode.G2C_Vote(message.DisbandChooiseNotice.pos, message.DisbandChooiseNotice.agree); break; case MessageId.G2C_DisbandChooiseResult: if (message.DisbandChooiseResult.disband) { if (message.DisbandChooiseResult.YuePaiTable != null) { NodeManager.OpenNode <CardResultShowNode>().Inits(message.DisbandChooiseResult.YuePaiTable); } else { PageManager.Instance.OpenPage <MainPage>(); TipManager.Instance.OpenTip(TipType.SimpleTip, "房间解散成功!"); } } else { TipManager.Instance.OpenTip(TipType.SimpleTip, "房间解散失败,有人拒绝解散"); } break; case MessageId.G2C_DisbandNotice: NodeManager.OpenNode <JiesanNode>().Inits(message.DisbandNotice.applyPos); break; case MessageId.G2C_DisbandResp: TipManager.Instance.OpenTip(TipType.SimpleTip, "解散申请已发出"); break; case MessageId.G2C_UserTalkResp: //麻将聊天 if (MaJangPage.Instance) { MaJangPage.Instance.PlayerChat(message.UserTalkResp); } break; case MessageId.G2C_MjKickPlayerRNotice: //麻将踢人 MaJangPage.Instance.LeaveById(message.mjKickedPlayerNotice.userId, true); break; case MessageId.G2C_MjKickPlayerResp: PageManager.Instance.OpenPage <MainPage>(); TipManager.Instance.OpenTip(TipType.SimpleTip, "您被踢出房间"); break; #endregion #region 斗地主 case MessageId.G2C_EnterDdzRoomResp: //进房间 LandlordsNet.G2C_EnterRoom(message.enterDdzRoomResp); break; case MessageId.G2C_DdzPrepareResp: LandlordsNet.G2C_ZhunbeiResp(message.ddzPrepareResp); break; case MessageId.G2C_PlayerRemovedNotice: //有玩家强退房间推送 for (int i = 0; i < message.playerRemovedNotice.userId.Count; i++) { LandlordsNet.G2C_LeaveRoomResp(message.playerRemovedNotice.userId[i].ToString(), message.playerRemovedNotice.reason); } break; case MessageId.G2C_DdzLeaveRoomResp: //有玩家退出房间推送 LandlordsNet.G2C_LeaveRoomResp(message.ddzLeaveRoomResp.userId.ToString(), 0); break; case MessageId.G2C_DdzKickedPlayerNotice: //我被踢 LandlordsNet.MeKicked(); break; case MessageId.G2C_DdzQueryPokerResp: //记牌器 LandlordsPage.Instance.componentView.jipaiqiPanel.InitValue(message.ddzQueryPokerResp.ddzPokerCounter); break; case MessageId.G2C_DdzFaPaiResp: //发牌推送 LandlordsNet.G2C_DealCard(message.ddzFaPaiResp); break; case MessageId.G2C_DdzJiaoFenNotice: //该我叫分推送 LandlordsNet.G2C_MeCallFen(); break; case MessageId.G2C_DdzQdzNotice: //该我叫地主 LandlordsNet.G2C_MeCallLandlords(); break; case MessageId.G2C_DdzChuPaiNotice: //该我出牌推送 LandlordsNet.G2C_MePop(); break; case MessageId.G2C_DdzJiaoFenResp: //叫分推送 LandlordsNet.G2C_PlayerCallResp(message.ddzJiaoFenResp); break; case MessageId.G2C_DdzQdzResp: //叫分推送 LandlordsNet.G2C_PlayerQdzResp(message.ddzQdzResp); break; case MessageId.G2C_DdzChuPaiResp: //出牌推送 LandlordsNet.G2C_PopResp(message.ddzChuPaiResp); break; case MessageId.G2C_DdzTuoguanResp: //托管推送 LandlordsNet.G2C_TuoguanResp(message.ddzTuoguanResp); break; case MessageId.G2C_DdzJieSuanResp: //结算单局推送 LandlordsNet.G2C_Result(message.ddzJieSuanResp); break; case MessageId.G2C_DdzYuePaiResult: //房卡房总结算 //NodeManager.OpenNode<CardResultShowNode>().Inits(message.yuePaiTableResp); break; case MessageId.G2C_DdzReconnectResp: //断线重连回应 if (message.ddzReconnectResp.tnf == 1) { TipManager.Instance.OpenTip(TipType.SimpleTip, "重连斗地主失败,进入大厅"); UserInfoModel.userInfo.inDzz = false; break; } StartCoroutine(LandlordsNet.G2C_Reconnect(message.ddzReconnectResp)); break; case MessageId.G2C_RemoveCRTable: PageManager.Instance.OpenPage <MainPage>(); break; case MessageId.G2C_DdzCanLeaveResp: //是否可以离开房间响应 LandlordsNet.G2C_IsCanLeaveResp(message.ddzCanLeaveResp); break; case MessageId.G2C_DdzJieSanNotice: //收到有人发起解散 if (message.ddzJieSanNotice.userId != UserInfoModel.userInfo.userId) { NodeManager.OpenNode <JiesanNode>().Inits(message.ddzJieSanNotice.userId); } break; case MessageId.G2C_DdzVoteNotice: //收到有人投票 JiesanNode.G2C_Vote(message.ddzVoteNotice.userId, message.ddzVoteNotice.yn); break; case MessageId.G2C_DdzJieSanResp: //推送解散结果 LandlordsNet.G2C_JiesanResult(message.ddzJieSanResp.success); break; case MessageId.G2C_DdzReplaceTableResp: if (message.ddzReplaceTableResp.userId == UserInfoModel.userInfo.userId) { LandlordsModel.Instance.Clear(); LandlordsPage.Instance.InitRoom(); } else { LandlordsNet.G2C_LeaveRoomResp(message.ddzReplaceTableResp.userId.ToString(), 0); } break; //case MessageId.inva //TipManager.Instance.OpenTip(TipType.ChooseTip, string.Format("您的好友{0}邀请您进入{1}一起玩耍", name, game), 0, () => // { // NodeManager.OpenNode<TipsEnterNode>().Inits(); // }); //break; case MessageId.G2C_DdzChatResp: //聊天 LandlordsNet.G2C_ChatResp(message.ddzChatResp); break; case MessageId.G2C_QueryPlayerBaseInfoResp: //请求玩家信息(弹框) GameRoleInfoNode.SetPlayerInfo(message.playerBaseInfo); break; #endregion #region 喇叭 case MessageId.G2C_BroadCastMsg: //有人发喇叭 GameMessage msg = new GameMessage() { type = message.broadCastMsg.horn.type, sender = message.broadCastMsg.horn.nickname, value = message.broadCastMsg.horn.content }; ChatModel.chatList.Add(msg); if (ChatModel.chatList.Count > ChatModel.MaxChatCount) { ChatModel.chatList[0] = msg; ChatModel.chatList.RemoveAt(ChatModel.chatList.Count - 1); } TrumpetNode trump_node = NodeManager.GetNode <TrumpetNode>(); if (trump_node) { trump_node.LoadItem(msg); } NoticeNode.Add(string.Format("{0}:{1}", msg.sender, msg.value)); if (message.broadCastMsg.horn.nickname == UserInfoModel.userInfo.nickName) { TipManager.Instance.OpenTip(TipType.SimpleTip, "喇叭发送成功!"); } break; #endregion //case MessageId.G2C_InviteFriendYuePaiResp: // TipManager.Instance.OpenTip(TipType.ChooseTip,"您的好友邀请您进入"+message.inviteFriendYuePaiResp.) //break; default: if (messageId != MessageId.G2C_HeartBeatResp) { UIUtils.Log("未处理的消息id :" + messageId); } break; } #endregion } else { ErrorMessage(message); } } while (!canHandleMessage) { yield return(new WaitForSecondsRealtime(0.1f)); } yield return(new WaitForSecondsRealtime(0.005f)); } }
void OnDestroy() { instance = null; }