public void OnReserve() { Connect.Shared.Emit("reserveseat", success: (json) => { var res = json.Int("will_reserveseat"); if (res == 1) { PokerUI.Toast("这手牌结束后进入留座离状态"); } }); Close(); }
public void SendRequest() { Connect.Shared.Emit(new Dictionary <string, object>() { { "f", "modify" }, { "args", dict } }, (data) => { var err = data.Dict("err"); foreach (KeyValuePair <string, object> item in err) { PokerUI.Toast(item.Value.ToString()); } }); }
public void TakeCoin() { float value = slider.value; Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("multiple", value / (100 * GameData.Shared.BB)); args.Add("ver", Application.version); if (aimClubID != "") { args.Add("club_id", aimClubID); } Connect.Shared.Emit(new Dictionary <string, object>() { { "f", "takecoin" }, { "args", args } }, (json, err) => { if (err == 1201) { _.PayFor(() => { RxSubjects.TakeCoin.OnNext(new RxData()); }); } else if (err == 1203) { PokerUI.Toast("联盟额度不足"); } else if (err == 0 && GameData.Shared.AllowClubs.Count > 1) { var clubs = GameData.Shared.AllowClubs; Func <object, bool> filter = (x) => { var d = x as Dictionary <string, object>; return(d.String("_id") == aimClubID); }; GameData.Shared.AllowClubs = clubs.Where((dict) => filter(dict)).ToList(); } GetComponent <DOPopup>().Close(); }); }
private void addEvents() { RxSubjects.Pass.Subscribe((e) => { Hide(); }).AddTo(this); RxSubjects.UnPass.Subscribe((e) => { Hide(); string type; switch (GameData.Shared.Type.Value) { case GameType.MTT: type = "购买"; break; case GameType.SNG: type = "报名"; break; default: type = "带入"; break; } PokerUI.Toast(string.Format("房主拒绝您的{0}申请", type)); }).AddTo(this); GameData.Shared.AuditCD.Subscribe((secs) => { if (secs > 0) { Show(secs); } else { Hide(); } }).AddTo(this); }
public void Enter() { // 复活金币不足,不弹出购买框;主动点击弹出购买框 Connect.Shared.Emit(new Dictionary <string, object>() { { "f", radata.type }, { "for_match", 1 } }, (json, err) => { if (err == 0) { if (json.ContainsKey("bankroll")) { radata.increase(); PokerUI.Toast(radata.successText); } else { PokerUI.Toast(string.Format("{0}申请已提交,等待房主审核中", radata.title)); } } else if (err == 1201) { PokerUI.Toast("金币不足,无法购买记分牌"); } else if (err == 1202) { PokerUI.Toast(string.Format("还有{0}申请在审核中", radata.title)); } else { PokerUI.Toast(string.Format("{0}失败", radata.title)); } }); GetComponent <DOPopup>().Close(); }
public void TakeCoin() { Connect.Shared.Emit(new Dictionary <string, object>() { { "f", "takecoin" }, { "args", new Dictionary <string, object> { { "multiple", int.Parse(EntryFee.text) } } } }, (json, err) => { if (err == 1201) { _.PayFor(() => { RxSubjects.TakeCoin.OnNext(new RxData()); }); } else if (err == 1203) { PokerUI.Toast("联盟额度不足"); } GetComponent <DOPopup>().Close(); }); }
private void registerEvents() { // 只允许初始化一次 if (isReady) { return; } GameData.Shared.LeftTime.Subscribe((value) => { if (!GameData.Shared.GameStarted.Value) { setText(TimeLeftGo, "未开始"); return; } setText(TimeLeftGo, _.SecondStr(value)); if (GameData.Shared.IsMatch()) { return; } if (value > 5 * 60) { hasShowEnding = false; } else { if (!hasShowEnding) { PokerUI.Toast("牌局将在5分钟内结束"); } hasShowEnding = true; } }).AddTo(this); RxSubjects.UnSeat.Subscribe((e) => { var uid = e.Data.String("uid"); if (uid == GameData.Shared.Uid && e.Data.Int("type") == 2) { PokerUI.Alert("您已连续3次超时,先站起来休息下吧~"); } }).AddTo(this); GameData.Shared.Ante.Subscribe((value) => { setBBText(); }).AddTo(this); GameData.Shared.Straddle.Subscribe((value) => { setBBText(); }).AddTo(this); GameData.Shared.PlayerCount.Where((value) => value > 0).Subscribe((value) => { setupSeats(value); }).AddTo(this); RxSubjects.Connecting.Subscribe((stat) => { LoadingModal.transform.SetAsLastSibling(); LoadingModal.SetActive(stat); }).AddTo(this); RxSubjects.Seating.Subscribe((action) => { foreach (var go in Seats) { var seat = go.GetComponent <Seat>(); if (action) { seat.Hide(); } else if (!GameData.Shared.Players.ContainsKey(seat.Index)) { seat.Show(); } } ExpressionButton.SetActive(action); }).AddTo(this); subsPublicCards(); subsPlayer(); subsRoomSetting(); RxSubjects.GameReset.Subscribe((_) => { infoGo.SetActive(false); PokerUI.DestroyElements(); }).AddTo(this); RxSubjects.Emoticon.Subscribe((e) => { if (GameSetting.emoticonClose) { return; } int fromSeatIndex = e.Data.Int("seat"); int toSeatIndex = e.Data.Int("toseat"); int pid = e.Data.Int("pid"); int[] canTurnEmo = { 4, 5, 6, 7, 10, 12 }; bool isToMe = false; var fromSeatPos = new Vector2(0, 1920); var toSeat = Seats[0]; foreach (var seat in Seats) { if (seat.GetComponent <Seat>().Index == fromSeatIndex && fromSeatIndex > -1) { fromSeatPos = seat.GetComponent <RectTransform>().anchoredPosition; } if (seat.GetComponent <Seat>().Index == toSeatIndex) { toSeat = seat; if (toSeatIndex == GameData.Shared.FindPlayerIndex(GameData.Shared.Uid)) { isToMe = true; } } } var em = PoolMan.Spawn("Emoticon/Emo" + pid); em.GetComponent <Emoticon>().Init(fromSeatPos, toSeat, isToMe, canTurnEmo.Contains(pid)); }).AddTo(this); var expressions = new Dictionary <string, Transform>(); RxSubjects.Expression.Subscribe((e) => { var expressionName = e.Data.String("expression"); var uid = e.Data.String("uid"); if (expressions.ContainsKey(uid)) { PoolMan.Despawn(expressions[uid]); expressions.Remove(uid); } var expression = PoolMan.Spawn("Expression"); expressions[uid] = expression; // 保存起来 Transform parent; if (uid == GameData.Shared.Uid) { parent = ExpressionButton.transform; //有可能出现点击表情时,玩家已经站起的现象 if (!parent.gameObject.activeInHierarchy) { return; } } else { var seatIndex = e.Data.Int("seat"); var aimSeat = Seats[0]; foreach (var seat in Seats) { if (seat.GetComponent <Seat>().Index == seatIndex) { aimSeat = seat; break; } } parent = aimSeat.GetComponentInChildren <PlayerOppo>().transform; } expression.GetComponent <Expression>().SetTrigger(expressionName, parent, () => { expressions.Remove(uid); }); }).AddTo(this); RxSubjects.MatchLook.Subscribe((e) => { if (GameData.Shared.Type.Value != GameType.MTT) { return; } var state = e.Data.Int("match_state"); // 比赛未开始 if (state < 10) { return; } var myself = e.Data.Dict("myself"); if (myself.Int("rank") >= 0) { PokerUI.ToastThenExit("您已被淘汰"); } }).AddTo(this); RxSubjects.MatchRank.Subscribe((json) => { // 输了之后以游客身份旁观 GameData.Shared.IsMatchState = false; var SNGWinner = PoolMan.Spawn("MatchWinner"); SNGWinner.GetComponent <DOPopup>().ShowModal(new Color(0, 0, 0, 0.6f), closeOnClick: false); SNGWinner.GetComponent <MatchWinner>().Init(json.Data); }).AddTo(this); RxSubjects.ShowAudio.Where(isGuest).Subscribe((json) => { var N = JSON.Parse(json); var name = N["name"].Value; SpkText.ShowMessage(String.Format("{0}发送了一段语音", name)); }).AddTo(this); RxSubjects.SendChat.Where(isGuest).Subscribe((json) => { var N = JSON.Parse(json); var name = N["name"].Value; var text = N["text"].Value; SpkText.ShowMessage(String.Format("{0}: {1}", name, text)); }).AddTo(this); RxSubjects.Award27.Subscribe((e) => { var win27Emo = PoolMan.Spawn("Win27Emo"); win27Emo.transform.SetParent(G.UICvs.transform, false); win27Emo.GetComponent <RectTransform>().anchoredPosition = Vector2.zero; }).AddTo(this); RxSubjects.GameOver.Subscribe((e) => { if (GameData.Shared.IsMatch()) { return; } var type = GameData.Shared.Type.Value; var count = GameData.Shared.PublicCards.Count; if (count < 5 && type != GameType.KingThree) { SeeLeftCard.SetActive(true); } else if (count < 3 && type == GameType.KingThree) { SeeLeftCard.SetActive(true); } }).AddTo(this); RxSubjects.GameStart.Subscribe((e) => { gameReload(); infoGo.SetActive(false); }).AddTo(this); RxSubjects.Look.Subscribe((e) => { gameReload(); if (GameData.Shared.InGame) { infoGo.SetActive(false); } }).AddTo(this); RxSubjects.Pass.Subscribe((e) => { var type = GameData.Shared.Type.Value; if (!GameData.Shared.IsMatch()) { var msg = "记分牌带入成功"; if (GameData.Shared.InGame) { msg += "(下一手生效)"; } PokerUI.Toast(msg); } else if (type == GameType.SNG) { PokerUI.Toast("报名成功"); } else if (type == GameType.MTT) { var inc = e.Data.Int("inc_bankroll"); PokerUI.Toast(string.Format("成功购买{0}记分牌(下一手生效)", inc)); } }).AddTo(this); RxSubjects.SomeOneSeeCard.Subscribe((e) => { var name = e.Data.String("name"); var go = (GameObject)GameObject.Instantiate(SeeCardTips, G.UICvs.transform); var cvg = go.GetComponent <CanvasGroup>(); var text = go.transform.Find("Text").GetComponent <Text>(); text.text = String.Format("<color=#4FC3F7FF>{0}</color>看了剩余公共牌", name); go.SetActive(true); cvg.alpha = 0; go.transform.SetParent(SeeCardTable.transform); cvg.DOFade(1, 0.2f).OnComplete(() => { Observable.Timer(TimeSpan.FromSeconds(2.5)).Subscribe((tmp) => { cvg.DOFade(0, 0.2f).OnComplete(() => { Destroy(go); }); }).AddTo(this); }); }).AddTo(this); RxSubjects.ToInsurance.Subscribe((e) => { GameData.Shared.InsuranceState.Value = true; var InsurancePopup = PoolMan.Spawn("Insurance"); InsurancePopup.GetComponent <Insurance>().Init(e.Data, true); }).AddTo(this); RxSubjects.ShowInsurance.Subscribe((e) => { var InsurancePopup = PoolMan.Spawn("Insurance"); InsurancePopup.GetComponent <Insurance>().Init(e.Data, false); }).AddTo(this); RxSubjects.RaiseBlind.Subscribe((e) => { var bb = e.Data.Int("big_blind"); var cd = e.Data.Int("blind_countdown"); GameData.Shared.BB = bb; GameData.Shared.LeftTime.OnNext(cd); GameData.Shared.Ante.Value = e.Data.Int("ante"); setBBText(); PokerUI.Toast(string.Format("盲注已升至{0}/{1}", bb / 2, bb)); if (GameData.Shared.Type.Value == GameType.MTT) { var lv = e.Data.Int("blind_lv"); // 下一级别无法重购 if (lv == GameData.MatchData.LimitLv - 2) { PokerUI.Toast("本级别过后将无法再重购"); } else if (lv == GameData.MatchData.LimitLv - 1) { PokerUI.Toast("本级别过后将无法再增购"); } } }).AddTo(this); RxSubjects.OffScore.Subscribe((e) => { var type = e.Data.Int("type"); if (type == 0) { PokerUI.Toast("您已提前下分,将在本局结束后结算"); return; } if (type != 1) { return; } var name = e.Data.String("name"); var avatar = e.Data.String("avatar"); var dt = e.Data.Dict("data"); var takecoin = dt.Int("takecoin"); var profit = dt.Int("bankroll") - takecoin; PoolMan.Spawn("OffScore").GetComponent <OffScore>().Show(avatar, takecoin, profit); // 已下分,bankroll为0 GameData.Shared.Bankroll.Value = 0; }).AddTo(this); RxSubjects.ToAddOn.Subscribe((e) => { var go = PoolMan.Spawn("RebuyOrAddon"); go.GetComponent <DOPopup>().Show(closeOnClick: false); go.GetComponent <RebuyOrAddon>().AddOn(true); }).AddTo(this); RxSubjects.ToRebuy.Subscribe((e) => { var go = PoolMan.Spawn("RebuyOrAddon"); go.GetComponent <DOPopup>().Show(closeOnClick: false); go.GetComponent <RebuyOrAddon>().Rebuy(true); }).AddTo(this); RxSubjects.GameEnd.Subscribe((e) => { // 关闭连接 Connect.Shared.CloseImmediate(); if (MatchWinner.IsSpawned) { return; } // 获取roomID,调用ExitCb后无法获取 var roomID = GameData.Shared.Room.Value; var matchID = GameData.Shared.MatchID; var ID = ""; var page = ""; // 清理 External.Instance.ExitCb(() => { switch (GameData.Shared.Type.Value) { case GameType.SNG: ID = roomID; page = "record_sng.html"; break; case GameType.MTT: ID = matchID; page = "record_mtt.html"; break; default: ID = roomID; page = "record.html"; break; } Commander.Shared.GameEnd(ID, page); }); }).AddTo(this); RxSubjects.MTTMatch.Subscribe((e) => { if (GameData.Shared.Type.Value != GameType.MTT) { return; } var type = e.Data.Int("type"); if (type == 3) { var player = GameData.Shared.GetMyPlayer(); if (player.IsValid()) { return; } var roomId = e.Data.String("data"); Connect.Shared.Enter(roomId, () => { getRoomEnter(); }); } else if (type == 6) { PokerUI.Toast("即将进入钱圈"); } }).AddTo(this); // Connect.Shared.Enter(GameData.Shared.Room.Value, () => { // getRoomEnter(); // }); }
private void subsRoomSetting() { GameData.Shared.Type.Subscribe((type) => { if (GameData.Shared.IsMatch()) { OwnerButton.SetActive(false); setStartButton(false); } else { OwnerButton.SetActive(true); } if (type == GameType.Normal) { matchLogo.SetActive(false); } else { setIconByType(GameData.Shared.Type.Value); } var p1 = PublicCardContainers[0].transform.parent.gameObject; var p5 = PublicCardContainers[4].transform.parent.gameObject; // 金山顺公共牌逻辑兼容 if (type == GameType.KingThree) { p1.SetActive(false); p5.SetActive(false); } else { p1.SetActive(true); p5.SetActive(true); } }).AddTo(this); GameData.Shared.GameStarted.Subscribe((started) => { if (GameData.Shared.Type.Value == GameType.MTT) { return; } if (!started) { setNotStarted(); } else { setStartButton(false); } }).AddTo(this); RxSubjects.Ending.Subscribe((e) => { PokerUI.Toast("房主提前结束牌局"); }).AddTo(this); GameData.Shared.IPLimit.Subscribe((_) => { setRoomSetting(); }).AddTo(this); GameData.Shared.GPSLimit.Subscribe((_) => { setRoomSetting(); }).AddTo(this); GameData.Shared.NeedInsurance.Subscribe((_) => { setRoomSetting(); }).AddTo(this); GameData.Shared.RoomName.Subscribe((name) => { gameInfoTexts[0].text = string.Format("[ {0} ]", name); }).AddTo(this); GameData.Shared.GameCode.Subscribe((code) => { if (!String.IsNullOrEmpty(code)) { InviteCodeGo.SetActive(true); setText(InviteCodeGo, String.Format("{0}", GameData.Shared.GameCode)); } else { InviteCodeGo.SetActive(false); } }).AddTo(this); GameData.Shared.TableNumber.Where((_) => GameData.Shared.Type.Value == GameType.MTT).Subscribe((num) => { if (num != 0) { gameInfoTexts[1].text = "牌桌" + num; } else { gameInfoTexts[1].text = "决赛桌"; } gameInfoTexts[2].text = ""; }).AddTo(this); GameData.MatchData.MatchRoomStatus.Subscribe((value) => { if (GameData.Shared.Type.Value != GameType.MTT) { return; } if (value == MatchRoomStat.WaitingStart) { setInfoText("等待全场同步发牌"); } else if (value == MatchRoomStat.Rest) { setInfoText("中场休息5分钟"); } else if (value == MatchRoomStat.WaitingFinal) { setInfoText("决赛等待中"); } else { infoGo.SetActive(false); } }).AddTo(this); GameData.Shared.Paused.Subscribe((pause) => { // 服务器升级 if (pause == 5) { PokerUI.DisAlert("服务器升级中…"); return; } if (GameData.Shared.IsMatch()) { return; } if (!GameData.Shared.GameStarted.Value) { return; } if (GameData.Shared.InGame || pause != 2) { infoGo.SetActive(false); } else { setInfoText("房主已暂停游戏"); } }).AddTo(this); RxSubjects.Pausing.Subscribe((e) => { var type = e.Data.Int("type"); if (type == 5) { var text = "服务器即将升级,牌局将强制暂停"; PokerUI.Toast(text); } else { if (GameData.Shared.InGame) { var text = "房主已暂停游戏(下一手生效)"; PokerUI.Toast(text); } } }).AddTo(this); RxSubjects.Modify.Subscribe((e) => { var data = e.Data; foreach (var item in e.Data) { var str = ""; switch (item.Key) { case "bankroll_multiple": GameData.Shared.BankrollMul = data.IL("bankroll_multiple"); str = "房主将记分牌倍数改为:" + GameData.Shared.BankrollMul[0] + "-" + GameData.Shared.BankrollMul[1]; PokerUI.Toast(str); break; case "time_limit": var timeLimit = data.Int("time_limit"); GameData.Shared.Duration += timeLimit; GameData.Shared.LeftTime.OnNext(GameData.Shared.LeftTime.Value + timeLimit); var time = data.Long("time_limit") / 3600f; var digit = "小时"; if (time < 1) { time = time * 60; digit = "分钟"; } str = "房主将牌局延长了" + time.ToString() + digit; PokerUI.Toast(str); break; case "ante": GameData.Shared.Ante.Value = data.Int("ante"); str = "房主将前注改为:" + GameData.Shared.Ante.Value; PokerUI.Toast(str); break; case "need_audit": GameData.Shared.NeedAudit = data.Int("need_audit") == 1; str = GameData.Shared.NeedAudit ? "房主开启了授权带入" : "房主关闭了授权带入"; PokerUI.Toast(str); break; case "straddle": GameData.Shared.Straddle.Value = data.Int("straddle") != 0; str = GameData.Shared.Straddle.Value ? "房主开启了Straddle" : "房主关闭了Straddle"; PokerUI.Toast(str); break; case "turn_countdown": GameData.Shared.SettingThinkTime = data.Int("turn_countdown"); str = "房主将思考时间改为" + GameData.Shared.SettingThinkTime + "秒"; PokerUI.Toast(str); break; case "off_score": var off = data.Int("off_score") == 1; GameData.Shared.OffScore.Value = off; str = off ? "房主开启了提前下分" : "房主关闭了提前下分"; PokerUI.Toast(str); break; default: break; } } }).AddTo(this); RxSubjects.KickOut.Subscribe((e) => { string str = e.Data.String("name") + "被房主请出房间"; PokerUI.Toast(str); }).AddTo(this); RxSubjects.StandUp.Subscribe((e) => { int seat = e.Data.Int("where"); if (seat > -1) { string str = e.Data.String("name") + "被房主强制站起"; PokerUI.Toast(str); } }).AddTo(this); GameData.Shared.TalkLimit.Subscribe((limit) => { TalkLimit(limit); }).AddTo(this); GameData.Shared.InsuranceState.Subscribe((limit) => { if (!GameData.Shared.NeedInsurance.Value) { return; } if (limit) { setInfoText("购买保险中,全场禁言…"); } else if (GameData.Shared.GameStarted.Value) { infoGo.SetActive(false); } }).AddTo(this); RxSubjects.NoTalking.Subscribe((e) => { string Uid = e.Data.String("uid"); bool type = e.Data.Int("type") == 1; string str = e.Data.String("name"); str += type ? "被房主禁言" : "被解除禁言"; PokerUI.Toast(str); }).AddTo(this); }
private void addEvents() { RxSubjects.Insurance.Subscribe((e) => { var uid = e.Data.String("uid"); var ct = e.Data.Int("ct"); var pot = e.Data.Int("pot"); var amount = e.Data.Int("amount"); var time = e.Data.Int("time"); var pay = e.Data.Int("pay"); var type = e.Data.Int("type"); var touid = e.Data.String("touid"); var player = GameData.Shared.FindPlayer(uid); var name = player.Name; var text = ""; var url = player.Avatar; var toName = GameData.Shared.FindPlayer(touid).Name; if (e.Data.ContainsKey("time")) { countdown.Value = time; } else if (disposable != null) { disposable.Dispose(); } if (type != 3) { if (SeePage.activeInHierarchy) { SeePage.SetActive(false); } } switch (type) { case 1: case 2: case 4: Hide(() => { var dt = new Dictionary <int, string>() { { 1, "多名领先玩家,将直接发牌" }, { 2, "无需风险控制,将直接发牌" }, { 4, "领先玩家选择直接发牌" } }; PokerUI.Toast(dt[type]); }); return; case 20: text = String.Format( "已购买<color=#18FFFFFF>{0}</color>张OUTS\n保费<color=#FFAB40FF>{1}</color>,预计赔付<color=#FFAB40FF>{2}</color>", ct, _.Num2CnDigit(amount), _.Num2CnDigit(pay)); break; case 3: SeePage.SetActive(true); text = cdText(time); GameData.Shared.InsuranceState.Value = true; break; case 11: if (amount == 0) { text = String.Format("获得保险赔付:<color=#FFAB40FF>{0}</color>", _.Num2CnDigit(pay)); } else { text = String.Format( "获得保险赔付:<color=#FFAB40FF>{0}</color>\n扣除保费:<color=#FFAB40FF>{1}</color>", _.Num2CnDigit(pay), _.Num2CnDigit(amount) ); } break; case 12: text = "未买中保险,牌面打平"; break; case 10: text = "<color=#FFAB40FF>继续领先</color>\n结算时将扣除保费"; break; case 13: text = string.Format("获得底池:<color=#FFAB40FF>{0}</color>\n扣除保费:<color=#FFAB40FF>{1}</color>", _.Num2CnDigit(pot), _.Num2CnDigit(amount)); break; case 14: text = string.Format("未买中保险\n被<color=#4FC3F7FF>{0}</color>反超", toName); break; default: Hide(); return; } MsgText.text = text; NameText.text = name; Avatar.GetComponent <Avatar>().SetImage(url); Show(time > 0); }).AddTo(this); countdown.Subscribe((time) => { if (time < 0) { if (disposable != null) { disposable.Dispose(); } } else { MsgText.text = cdText(time); } }).AddTo(this); RxSubjects.Moretime.Subscribe((e) => { var model = e.Data.ToObject <MoreTimeModel>(); if (model.IsRound()) { return; } countdown.Value = model.total; }).AddTo(this); RxSubjects.GameOver.Subscribe((_) => { Hide(); }).AddTo(this); RxSubjects.ToInsurance.Subscribe((_) => { Hide(); }).AddTo(this); RxSubjects.Look.Subscribe((_) => { Hide(); }).AddTo(this); }