예제 #1
0
    void Awake()
    {
        RxSubjects.TakeCoin.Subscribe((e) => {
            if (e.Data != null)
            {
                GameData.Shared.Coins = e.Data.Int("coins");
            }

            //根据类别生成不同预制体
            Transform transform;
            if (!GameData.Shared.IsMatch())
            {
                transform = PoolMan.Spawn("Supplement");
            }
            else
            {
                transform = PoolMan.Spawn("JoinMatch");
            }


            transform.GetComponent <DOPopup>().Show(() => {
                var player = GameData.Shared.GetMyPlayer();

                if (player.Index == -1 || player.Bankroll.Value > 0)
                {
                    return;
                }

                Connect.Shared.Emit("unseat");
            });
        }).AddTo(this);

        RxSubjects.Bye.Subscribe((e) => {
            var type = e.Data.Int("type");

            if (type == 2)
            {
                PokerUI.ConflictAlert();
            }
            else if (type == 3)
            {
                PokerUI.DisAlert("您已被房主踢出牌局");
            }
        }).AddTo(this);
    }
예제 #2
0
파일: Controller.cs 프로젝트: rfHu/poker
    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);
    }