Пример #1
0
        public SprotoTypeBase OnReqJoin(SprotoTypeBase requestObj)
        {
            S2cSprotoType.join.request obj = requestObj as S2cSprotoType.join.request;
            if (obj != null)
            {
                long offset = 0;
                if (obj.p.idx > _myidx)
                {
                    offset = obj.p.idx - _myidx;
                }
                else
                {
                    offset = obj.p.idx + 4 - _myidx;
                }
                switch (offset)
                {
                case 1: {
                    var rplayer = new Game.RightPlayer(_ctx, this);
                    rplayer.Sid        = (uint)obj.p.sid;
                    rplayer.Idx        = (int)obj.p.idx;
                    rplayer.Chip       = (int)obj.p.chip;
                    rplayer.Sex        = (int)obj.p.sex;
                    rplayer.Name       = obj.p.name;
                    rplayer.Controller = _controller;
                    rplayer.Init();
                    _playes[obj.p.idx] = rplayer;
                    if (_loadedcards)
                    {
                        _controller.Scene.SetupRightPlayer();
                    }
                }
                break;

                case 2: {
                    var tplayer = new Bacon.Game.TopPlayer(_ctx, this);
                    tplayer.Sid        = (uint)obj.p.sid;
                    tplayer.Idx        = (int)obj.p.idx;
                    tplayer.Chip       = (int)obj.p.chip;
                    tplayer.Sex        = (int)obj.p.sex;
                    tplayer.Name       = obj.p.name;
                    tplayer.Controller = _controller;
                    tplayer.Init();
                    _playes[obj.p.idx] = tplayer;
                    if (_loadedcards)
                    {
                        _controller.Scene.SetupTopPlayer();
                    }
                }
                break;

                case 3: {
                    var lplayer = new Bacon.Game.LeftPlayer(_ctx, this);
                    lplayer.Sid        = (uint)obj.p.sid;
                    lplayer.Idx        = (int)obj.p.idx;
                    lplayer.Chip       = (int)obj.p.chip;
                    lplayer.Sex        = (int)obj.p.sex;
                    lplayer.Name       = obj.p.name;
                    lplayer.Controller = _controller;
                    lplayer.Init();
                    _playes[obj.p.idx] = lplayer;
                    if (_loadedcards)
                    {
                        _controller.Scene.SetupLeftPlayer();
                    }
                }
                break;

                default:
                    break;
                }
            }
            _joined++;
            _online++;
            SendStep();

            S2cSprotoType.join.response responseObj = new S2cSprotoType.join.response();
            responseObj.errorcode = Errorcode.SUCCESS;
            return(responseObj);
        }
Пример #2
0
        public void OnRspJoin(SprotoTypeBase responseObj)
        {
            C2sSprotoType.join.response obj = responseObj as C2sSprotoType.join.response;
            if (obj.errorcode == Errorcode.SUCCESS)
            {
                _roomid = obj.roomid;
                _max    = obj.room_max;
                //_host = false;

                _controller = (GameController)_ctx.Push(typeof(GameController));

                Player player = new Bacon.Game.BottomPlayer(_ctx, this);
                player.Sid        = (uint)obj.me.sid;
                player.Idx        = (int)obj.me.idx;
                player.Chip       = (int)obj.me.chip;
                player.Sex        = (int)obj.me.sex;
                player.Name       = obj.me.name;
                player.Controller = _controller;
                player.Init();

                _myidx          = obj.me.idx;
                _playes[_myidx] = player;
                UnityEngine.Debug.Assert(_ctx.U.Subid == obj.me.sid);

                _joined++;
                _online++;

                if (obj.ps != null && obj.ps.Count > 0)
                {
                    for (int i = 0; i < obj.ps.Count; i++)
                    {
                        var  item   = obj.ps[i];
                        long offset = 0;
                        if (item.idx > _myidx)
                        {
                            offset = item.idx - _myidx;
                        }
                        else
                        {
                            offset = item.idx + 4 - _myidx;
                        }
                        switch (offset)
                        {
                        case 1: {
                            var rplayer = new Bacon.Game.RightPlayer(_ctx, this);
                            rplayer.Sid        = (uint)item.sid;
                            rplayer.Idx        = (int)item.idx;
                            rplayer.Chip       = (int)item.chip;
                            rplayer.Sex        = (int)item.sex;
                            rplayer.Name       = item.name;
                            rplayer.Controller = _controller;
                            rplayer.Init();
                            _playes[item.idx] = rplayer;
                        }
                        break;

                        case 2: {
                            var tplayer = new Bacon.Game.TopPlayer(_ctx, this);
                            tplayer.Sid        = (uint)item.sid;
                            tplayer.Idx        = (int)item.idx;
                            tplayer.Chip       = (int)item.chip;
                            tplayer.Sex        = (int)item.sex;
                            tplayer.Name       = item.name;
                            tplayer.Controller = _controller;
                            tplayer.Init();
                            _playes[item.idx] = tplayer;
                        }
                        break;

                        case 3: {
                            var lplayer = new Bacon.Game.LeftPlayer(_ctx, this);
                            lplayer.Sid        = (uint)item.sid;
                            lplayer.Idx        = (int)item.idx;
                            lplayer.Chip       = (int)item.chip;
                            lplayer.Sex        = (int)item.sex;
                            lplayer.Name       = item.name;
                            lplayer.Controller = _controller;
                            lplayer.Init();
                            _playes[item.idx] = lplayer;
                        }
                        break;

                        default:
                            break;
                        }
                        _joined++;
                        _online++;
                    }
                }
                SendStep();
            }
            else if (obj.errorcode == Errorcode.NOEXiST_ROOMID)
            {
                AppContext ctx = _ctx as AppContext;
                TipsMgr    mgr = ctx.GetTipsMgr();
                mgr.TipsContent = "不存在相应的房间号";

                MainController controller = _ctx.Peek <MainController>();

                //_ctx.EnqueueRenderQueue(controller.render)
            }
            else if (obj.errorcode == Errorcode.ROOM_FULL)
            {
                MainController controller = _ctx.Peek <MainController>();
                //controller.ShowTips("房间已经满了");
            }
        }