Exemple #1
0
    private void subsRpcRet()
    {
        manager.Socket.On("rpc_ret", (socket, packet, args) => {
            if (args.Length == 0)
            {
                return;
            }

            var json = args[0] as Dictionary <string, object>;

            if (json == null)
            {
                return;
            }

            var rid = json.String("roomid");
            if (!string.IsNullOrEmpty(rid) && rid != GameData.Shared.Room.Value)
            {
                return;
            }

            // @FIXME: ret可能是string?
            var ret = json.Dict("ret");
            if (ret.ContainsKey("cmds"))
            {
                GameData.MyCmd.SetCmd(ret.Dict("cmds"));
            }

            if (ret.ContainsKey("coins"))
            {
                GameData.Shared.Coins = ret.Int("coins");
            }

            var err = json.Int("err");

            // 公共错误处理
            if (err == 403)
            {
                PokerUI.ConflictAlert();
            }
            else if (err == 406 && !MatchWinner.IsSpawned)                 // 弹出获奖框时,不能提示
            {
                PokerUI.ToastThenExit("牌局不存在!");
            }
            else
            {
                int seq = json.Int("seq");
                if (instance.successCallbacks.ContainsKey(seq))
                {
                    instance.successCallbacks[seq](ret, err);
                }
            }
        });
    }
Exemple #2
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);
    }