コード例 #1
0
ファイル: BottomPlayer.cs プロジェクト: wy182000/mahjong
        protected override void RenderSettle()
        {
            long chip = 0;
            long left = 0;

            if (_settle.Count > 0)
            {
                SettlementItem item = _settle[0];
                if (item.TuiSui == 1)
                {
                    _com.Head.SetGold((int)left);
                    _com.Head.ShowWAL("退税");

                    Sequence mySequence = DOTween.Sequence();
                    mySequence.AppendInterval(1.0f)
                    .AppendCallback(() => {
                        _com.Head.ShowWAL(string.Format("{0}", chip));
                    })
                    .AppendInterval(1.0f)
                    .AppendCallback(() => {
                        Command cmd = new Command(MyEventCmd.EVENT_SETTLE_NEXT);
                        _ctx.Enqueue(cmd);
                    });
                }
                else
                {
                    Sequence mySequence = DOTween.Sequence();
                    mySequence.AppendInterval(1.0f)
                    .AppendCallback(() => {
                        Command cmd = new Command(MyEventCmd.EVENT_SETTLE_NEXT);
                        _ctx.Enqueue(cmd);
                    });
                }
            }
        }
コード例 #2
0
ファイル: GameController.cs プロジェクト: wy182000/mahjong
        private void OnSettleNext(EventCmd e)
        {
            _oknum++;
            if (_oknum >= _service.Max)
            {
                if (_settlesidx >= _settles.Count)
                {
                    C2sSprotoType.step.request request = new C2sSprotoType.step.request();
                    request.idx = _service.MyIdx;
                    _ctx.SendReq <C2sProtocol.step>(C2sProtocol.step.Tag, request);
                    return;
                }

                _service.Foreach((Player player) => {
                    player.ClearSettle();

                    S2cSprotoType.settlementitem si = null;
                    S2cSprotoType.settle settle     = _settles[_settlesidx];
                    long idx = 0;
                    if (player.Idx == 1)
                    {
                        idx = 1;
                        if (settle.p1 != null)
                        {
                            si = settle.p1;
                        }
                    }
                    else if (player.Idx == 2)
                    {
                        idx = 2;
                        if (settle.p2 != null)
                        {
                            si = settle.p2;
                        }
                    }
                    else if (player.Idx == 3)
                    {
                        idx = 3;
                        if (settle.p3 != null)
                        {
                            si = settle.p3;
                        }
                    }
                    else if (player.Idx == 4)
                    {
                        idx = 4;
                        if (settle.p4 != null)
                        {
                            si = settle.p4;
                        }
                    }
                    if (si != null)
                    {
                        SettlementItem item = new SettlementItem();
                        item.Idx            = si.idx;
                        item.Chip           = si.chip; // 有正负
                        item.Left           = si.left; // 以次值为准

                        item.Win  = si.win;
                        item.Lose = si.lose;

                        item.Gang   = si.gang;
                        item.HuCode = si.hucode;
                        item.HuJiao = si.hujiao;
                        item.HuGang = si.hugang;
                        item.HuaZhu = si.huazhu;
                        item.DaJiao = si.dajiao;
                        item.TuiSui = si.tuisui;

                        _service.GetPlayer(idx).AddSettle(item);
                        _service.GetPlayer(idx).Settle();
                    }
                });
                _settlesidx++;
            }
        }
コード例 #3
0
ファイル: GameController.cs プロジェクト: wy182000/mahjong
        public SprotoTypeBase OnGang(SprotoTypeBase requestObj)
        {
            S2cSprotoType.gang.request obj = requestObj as S2cSprotoType.gang.request;
            try {
                _service.Foreach((Player player) => {
                    player.ClearCall();
                    player.ClearSettle();
                });

                if (OpCodes.OPCODE_ANGANG == obj.code)
                {
                    _service.GetPlayer(obj.idx).Gang(OpCodes.OPCODE_ANGANG, obj.card, obj.hor, _service.GetPlayer(obj.idx), _lastCard);
                }
                else if (OpCodes.OPCODE_ZHIGANG == obj.code)
                {
                    UnityEngine.Debug.Assert(_lastCard.Value == obj.card);
                    _service.GetPlayer(obj.idx).Gang(OpCodes.OPCODE_ZHIGANG, obj.card, obj.hor, _service.GetPlayer(_lastidx), _lastCard);
                }
                else if (OpCodes.OPCODE_BUGANG == obj.code)
                {
                    _service.GetPlayer(obj.idx).Gang(OpCodes.OPCODE_BUGANG, obj.card, obj.hor, _service.GetPlayer(_lastidx), _lastCard);
                }

                _settles    = obj.settles;
                _settlesidx = 0;

                _service.Foreach((Player player) => {
                    S2cSprotoType.settlementitem si = null;
                    S2cSprotoType.settle settle     = _settles[_settlesidx];
                    long idx = 0;
                    if (player.Idx == 1)
                    {
                        idx = 1;
                        if (settle.p1 != null)
                        {
                            si = settle.p1;
                        }
                    }
                    else if (player.Idx == 2)
                    {
                        idx = 2;
                        if (settle.p2 != null)
                        {
                            si = settle.p2;
                        }
                    }
                    else if (player.Idx == 3)
                    {
                        idx = 3;
                        if (settle.p3 != null)
                        {
                            si = settle.p3;
                        }
                    }
                    else if (player.Idx == 4)
                    {
                        idx = 4;
                        if (settle.p4 != null)
                        {
                            si = settle.p4;
                        }
                    }
                    if (si != null)
                    {
                        SettlementItem item = new SettlementItem();
                        item.Idx            = si.idx;
                        item.Chip           = si.chip; // 有正负
                        item.Left           = si.left; // 以次值为准

                        item.Win  = si.win;
                        item.Lose = si.lose;

                        item.Gang   = si.gang;
                        item.HuCode = si.hucode;
                        item.HuJiao = si.hujiao;
                        item.HuGang = si.hugang;
                        item.HuaZhu = si.huazhu;
                        item.DaJiao = si.dajiao;
                        item.TuiSui = si.tuisui;

                        _service.GetPlayer(idx).AddSettle(item);
                        _service.GetPlayer(idx).GangSettle();
                    }
                });

                S2cSprotoType.gang.response responseObj = new S2cSprotoType.gang.response();
                responseObj.errorcode = Errorcode.SUCCESS;
                return(responseObj);
            } catch (Exception ex) {
                UnityEngine.Debug.LogException(ex);

                S2cSprotoType.gang.response responseObj = new S2cSprotoType.gang.response();
                responseObj.errorcode = Errorcode.SUCCESS;
                return(responseObj);
            }
        }
コード例 #4
0
ファイル: GameController.cs プロジェクト: wy182000/mahjong
        public SprotoTypeBase OnHu(SprotoTypeBase requestObj)
        {
            S2cSprotoType.hu.request obj = requestObj as S2cSprotoType.hu.request;
            try {
                _service.Foreach((Player player) => {
                    player.ClearCall();
                    player.ClearSettle();
                });

                _oknum    = 0;
                _huscount = obj.hus.Count;
                if (obj.hus.Count > 1)
                {
                    // 一炮多响
                }

                long dian = 0;
                for (int i = 0; i < obj.hus.Count; i++)
                {
                    S2cSprotoType.huinfo huinfo = obj.hus[i];
                    Card card = _lastCard;
                    if (dian == 0)
                    {
                        dian = huinfo.dian;
                    }
                    else
                    {
                        UnityEngine.Debug.Assert(dian == huinfo.dian);
                    }

                    Player player = _service.GetPlayer(huinfo.idx);
                    player.Hu(obj.hus[i].code, obj.hus[i].card, obj.hus[i].jiao, obj.hus[i].gang, obj.hus[i].dian, _service.GetPlayer(obj.hus[i].dian), card);
                }

                _settles    = obj.settles;
                _settlesidx = 0;

                _service.Foreach((Player player) => {
                    for (int i = 0; i < _settles.Count; i++)
                    {
                        S2cSprotoType.settlementitem si = null;
                        S2cSprotoType.settle settle     = _settles[i];
                        long idx = 0;
                        if (player.Idx == 1)
                        {
                            idx = 1;
                            if (settle.p1 != null)
                            {
                                si = settle.p1;
                            }
                        }
                        else if (player.Idx == 2)
                        {
                            idx = 2;
                            if (settle.p2 != null)
                            {
                                si = settle.p2;
                            }
                        }
                        else if (player.Idx == 3)
                        {
                            idx = 3;
                            if (settle.p3 != null)
                            {
                                si = settle.p3;
                            }
                        }
                        else if (player.Idx == 4)
                        {
                            idx = 4;
                            if (settle.p4 != null)
                            {
                                si = settle.p4;
                            }
                        }
                        if (si != null)
                        {
                            SettlementItem item = new SettlementItem();
                            item.Idx            = si.idx;
                            item.Chip           = si.chip; // 有正负
                            item.Left           = si.left; // 以次值为准

                            item.Win  = si.win;
                            item.Lose = si.lose;

                            item.Gang   = si.gang;
                            item.HuCode = si.hucode;
                            item.HuJiao = si.hujiao;
                            item.HuGang = si.hugang;
                            item.HuaZhu = si.huazhu;
                            item.DaJiao = si.dajiao;
                            item.TuiSui = si.tuisui;

                            _service.GetPlayer(idx).AddSettle(item);
                            _service.GetPlayer(idx).HuSettle();
                        }
                    }
                });

                S2cSprotoType.hu.response responseObj = new S2cSprotoType.hu.response();
                responseObj.errorcode = Errorcode.SUCCESS;
                return(responseObj);
            } catch (Exception ex) {
                UnityEngine.Debug.LogException(ex);

                S2cSprotoType.hu.response responseObj = new S2cSprotoType.hu.response();
                responseObj.errorcode = Errorcode.SUCCESS;
                return(responseObj);
            }
        }
コード例 #5
0
ファイル: GameController.cs プロジェクト: wy182000/mahjong
        public SprotoTypeBase OnFinalSettle(SprotoTypeBase requestObj)
        {
            try {
                S2cSprotoType.final_settle.request obj = requestObj as S2cSprotoType.final_settle.request;

                _ui.ShowOver();

                _service.Foreach((Player player) => {
                    player.ClearSettle();
                });

                _service.Foreach((Player player) => {
                    List <S2cSprotoType.settlementitem> settle = null;
                    long idx = 0;
                    if (player.Idx == 1)
                    {
                        idx = 1;
                        if (obj.p1 != null)
                        {
                            settle = obj.p1;
                        }
                    }
                    else if (player.Idx == 2)
                    {
                        idx = 2;
                        if (obj.p2 != null)
                        {
                            settle = obj.p2;
                        }
                    }
                    else if (player.Idx == 3)
                    {
                        idx = 3;
                        if (obj.p3 != null)
                        {
                            settle = obj.p3;
                        }
                    }
                    else if (player.Idx == 4)
                    {
                        idx = 4;
                        if (obj.p4 != null)
                        {
                            settle = obj.p4;
                        }
                    }

                    if (settle != null && settle.Count > 0)
                    {
                        for (int i = 0; i < settle.Count; i++)
                        {
                            SettlementItem item = new SettlementItem();
                            item.Idx            = settle[i].idx;
                            item.Chip           = settle[i].chip; // 有正负
                            item.Left           = settle[i].left; // 以次值为准

                            item.Win  = settle[i].win;
                            item.Lose = settle[i].lose;

                            item.Gang   = settle[i].gang;
                            item.HuCode = settle[i].hucode;
                            item.HuJiao = settle[i].hujiao;
                            item.HuGang = settle[i].hugang;
                            item.HuaZhu = settle[i].huazhu;
                            item.DaJiao = settle[i].dajiao;
                            item.TuiSui = settle[i].tuisui;

                            _service.GetPlayer(idx).AddSettle(item);
                        }

                        _service.GetPlayer(idx).FinalSettle();
                    }
                });

                S2cSprotoType.final_settle.response responseObj = new S2cSprotoType.final_settle.response();
                responseObj.errorcode = Errorcode.SUCCESS;
                return(responseObj);
            } catch (Exception ex) {
                S2cSprotoType.final_settle.response responseObj = new S2cSprotoType.final_settle.response();
                responseObj.errorcode = Errorcode.FAIL;
                return(responseObj);
            }
        }