示例#1
0
        //--------------------吃牌------------------------------------
        public void OnChi()
        {
            var          dataCenter = GameCenter.DataCenter;
            List <int[]> findList   = FindCanChi();
            Action <int> sendCall   = (index) =>
            {
                Network.OnRequestC2S((sfs) =>
                {
                    sfs.PutInt(RequestKey.KeyType, NetworkProtocol.MJRequestTypeCPG);
                    sfs.PutInt(ProtocolKey.KeyTType, OperateKey.OpreateChi);
                    sfs.PutIntArray(RequestKey.KeyCards, findList[index]);
                    return(sfs);
                });
            };

            if (findList.Count > 1)
            {
                ChooseCgArgs args = new ChooseCgArgs()
                {
                    FindList      = findList,
                    ConfirmAction = sendCall,
                    OutPutCard    = dataCenter.ThrowoutCard,
                    Type          = ChooseCgArgs.ChooseType.ChooseCg,
                };
                //通知UI提示选择
                GameCenter.EventHandle.Dispatch((int)UIEventProtocol.ShowChooseOperate, args);
            }
            else
            {
                sendCall(0);
            }
        }
示例#2
0
        public void OnTing(HandcardStateTyps type)
        {
            var tingList = GameCenter.DataCenter.OneselfData.TingList;
            var groups   = GameCenter.Scene.MahjongGroups;

            if (tingList.Count != 0)
            {
                ChooseCgArgs args = new ChooseCgArgs()
                {
                    Type             = ChooseCgArgs.ChooseType.ChooseTing,
                    CancelTingAction = () => { groups.PlayerHand.SetHandCardState(HandcardStateTyps.Normal); }
                };
                //通知UI提示选择
                GameCenter.EventHandle.Dispatch((int)UIEventProtocol.ShowChooseOperate, args);
                groups.PlayerHand.SetHandCardState(type, tingList);
            }
        }
示例#3
0
        public void ChooseNiuTing(List <int[]> findList, int value)
        {
            Action <int> sendCall = (index) =>
            {
                Network.OnRequestC2S((sfs) =>
                {
                    sfs.PutInt(RequestKey.KeyType, NetworkProtocol.MJRequestTypeCPG);
                    sfs.PutInt(ProtocolKey.KeyTType, OperateKey.OpreateChi);
                    sfs.PutIntArray(RequestKey.KeyCards, findList[index]);
                    return(sfs);
                });
            };
            ChooseCgArgs args = new ChooseCgArgs()
            {
                FindList      = findList,
                ConfirmAction = sendCall,
                OutPutCard    = value,
                Type          = ChooseCgArgs.ChooseType.ChooseTing
            };

            //通知UI提示选择
            GameCenter.EventHandle.Dispatch((int)UIEventProtocol.ShowChooseOperate, args);
        }
示例#4
0
        //--------------------杠牌------------------------------------
        public void OnGang()
        {
            var          dataCenter = GameCenter.DataCenter;
            var          findList   = FindCanGang();
            Action <int> sendCall   = (index) =>
            {
                Network.OnRequestC2S((sfs) =>
                {
                    if (findList[index].type != MiscUtility.DefInt)
                    {
                        sfs.PutInt(RequestKey.KeyType, findList[index].type);
                    }
                    if (findList[index].ttype != MiscUtility.DefInt)
                    {
                        sfs.PutInt(ProtocolKey.KeyTType, findList[index].ttype);
                    }
                    if (findList[index].cards != null && findList[index].ttype != NetworkProtocol.CPG_ZhuaGang)
                    {
                        sfs.PutIntArray(RequestKey.KeyCards, findList[index].cards);
                    }
                    else if (findList[index].cards != null && findList[index].ttype == NetworkProtocol.CPG_ZhuaGang)
                    {
                        sfs.PutInt(RequestKey.KeyOpCard, findList[index].cards[0]);
                    }
                    return(sfs);
                });
            };

            //如果找到的杠 大于1
            if (findList.Count > 1)
            {
                var gangcard = dataCenter.GangCard;
                if (gangcard.Count > 0)
                {
                    //根据server 指定杠牌
                    var tempFindList = new List <FindGangData>();
                    for (int i = 0; i < gangcard.Count; i++)
                    {
                        var gang = findList.Find(d => d.cards[0] == gangcard[i]);
                        tempFindList.Add(gang);
                    }
                    findList = tempFindList;
                }
                gangcard.Clear();

                //如果手中又四张赖子牌, 过滤赖子牌
                int laizi = GameCenter.DataCenter.Game.LaiziCard;
                if (findList.Exists(d => d.cards[0] == laizi))
                {
                    findList.RemoveAll(d => d.cards[0] == laizi);
                }

                if (findList.Count == 1)
                {
                    sendCall(0);
                }
                else
                {
                    ChooseCgArgs args = new ChooseCgArgs()
                    {
                        ConfirmAction = sendCall,
                        OutPutCard    = dataCenter.ThrowoutCard,
                        Type          = ChooseCgArgs.ChooseType.ChooseCg,
                    };
                    args.FindList = GetGangList(findList);
                    //通知UI提示选择
                    GameCenter.EventHandle.Dispatch((int)UIEventProtocol.ShowChooseOperate, args);
                }
            }
            else
            {
                sendCall(0);
            }
        }