Esempio n. 1
0
        /// <summary>
        /// 当玩家有对手牌进行点击操作时
        /// </summary>
        /// <param name="args"></param>
        private void OnHdCdsCtrlEvent(HdCdCtrlEvtArgs args)
        {
            //如果不该自己行动
            if (!_isMyTurn)
            {
                return;
            }

            //如果没有选牌
            if (args.SelectedCds.Length == 0)
            {
                if (ChuPaiBtn.activeSelf)
                {
                    SetBtnState(ChuPaiBtn, false);
                }

                _onoffIchosecCds = true;
                return;
            }

            var selectedCds = args.SelectedCds;

            var lastOutCds = _lastOutData.GetIntArray(RequestKey.KeyCards);

            //-----------------------start 智能选牌过程-------有赖子,或者开关关闭则不用智能选牌----------------------------
            bool isgetcdsWithoutCompare = false;    //标记是不是在自己出动出牌时做出的智能选牌

            int[] mayOutCds      = null;
            bool  selCdshasLaizi = PokerRuleUtil.CheckHaslz(selectedCds);

            if (!selCdshasLaizi && _onoffIchosecCds)
            {
                if (_lastOutData.GetInt(RequestKey.KeySeat) == App.GetGameData <DdzGameData>().SelfSeat)
                {
                    mayOutCds = _checkCardTool.GetcdsWithOutCompare(selectedCds, HdCdsListTemp.ToArray());
                    isgetcdsWithoutCompare = true;
                }
                else
                {
                    SetBtnActive(BuYaoBtn, true);
                    mayOutCds = _checkCardTool.ChkCanoutCdListWithLastCdList(selectedCds,
                                                                             _cardManager.GetTishiGroupDic, lastOutCds);
                }
            }
            //---------------------------------------------------------------------------------------end


            /*            //---start---------------使智能选牌出了相同的牌型,不重复执行-----------------------
             *          var haschosemayOutCds = DDzUtil.IsTwoArrayEqual(HdCdsCtrl.SortCds(_mayoutCdsTemp), HdCdsCtrl.SortCds(mayOutCds));
             *          _mayoutCdsTemp = mayOutCds;
             *          //如果上次智能选牌和本次相同,则直接取消一次智能选牌
             *          if (haschosemayOutCds)
             *          {
             *              mayOutCds = null;
             *          }
             *          //----------------------------------------------------------------------------------end*/



            if (mayOutCds == null || mayOutCds.Length == 0)
            {
                bool isMatch;

                //如果_lastOutData不是自己出牌
                if (_lastOutData.GetInt(RequestKey.KeySeat) != App.GetGameData <DdzGameData>().SelfSeat)
                {
                    var lastoutcds = new List <int>();

                    if (lastOutCds != null)
                    {
                        lastoutcds.AddRange(lastOutCds);
                    }

                    var cardTypeDic = _cardManager.GetAutoCardsList(selectedCds, selCdshasLaizi, lastoutcds.ToArray());
                    isMatch = cardTypeDic != null && cardTypeDic.Count > 0;
                }
                else
                {
                    var cardTypeDic = _cardManager.GetAutoCardsList(selectedCds, selCdshasLaizi, null);
                    isMatch = cardTypeDic != null && cardTypeDic.Count > 0;
                }

                if (isMatch)
                {
                    HdCdctrlInstance.UpCdList(selectedCds);
                }
                else
                {
                    if (ChuPaiBtn.activeSelf)
                    {
                        SetBtnState(ChuPaiBtn, false);
                    }
                    //DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn);
                    return;
                }
            }
            else
            {
                if (!ChooseMayOutCards(mayOutCds, selectedCds)) //如果选中的牌不能出
                {
                    if (ChuPaiBtn.activeSelf)
                    {
                        SetBtnState(ChuPaiBtn, false);
                    }
                    return;
                }
            }


            //经过智能检索后最后检查一遍抬出的牌是否合法----start---

            var finalType = PokerRuleUtil.GetCdsType(HdCdctrlInstance.GetUpCdList().ToArray());

            SetBtnState(ChuPaiBtn, true);
            //DDzUtil.ActiveBtn(ChuPaiBtn, DisChuPaiBtn);

            if (finalType != CardType.None && finalType != CardType.Exception)
            {
                //如果选出的牌型不是那种单牌,或者对子的小牌型,就先关闭智能选牌
                if (isgetcdsWithoutCompare && finalType != CardType.C1 && finalType != CardType.C2)
                {
                    _onoffIchosecCds = false;
                }
                else if (!isgetcdsWithoutCompare)
                {
                    _onoffIchosecCds = false;
                }
            }


            //------------end
        }
Esempio n. 2
0
        /// <summary>
        /// 当玩家有对手牌进行点击操作时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnHdCdsCtrlEvent(object sender, HdCdCtrlEvtArgs args)
        {
            //如果不该自己行动
            if (!ChuPaiBtn.activeSelf && !DisChuPaiBtn.activeSelf)
            {
                return;
            }

            //如果没有选牌
            if (args.SelectedCds.Length == 0)
            {
                DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn);
                _onoffIchosecCds = true;
                return;
            }

            var selectedCds = args.SelectedCds;
            var lastOutCds  = _lastOutData.GetIntArray(RequestKey.KeyCards);

            //如果直接全选了所有手牌,且不是关别家的牌是自己主动出的情况下,检查能不能一次全出
            if (selectedCds.Length == HdCdsListTemp.Count && _lastOutData.GetInt(RequestKey.KeySeat) == App.GetGameData <GlobalData>().GetSelfSeat)
            {
                var canOutType = CheckCanOutCdsOneTime(new CdSplitStruct(HdCdsListTemp.ToArray()));
                if (canOutType != CardType.None && canOutType != CardType.Exception)
                {
                    HdCdctrlInstance.UpAllHandCds();
                    DDzUtil.ActiveBtn(ChuPaiBtn, DisChuPaiBtn);
                    return;
                }
            }



            //-----------------------start 智能选牌过程-------有赖子,或者开关关闭则不用智能选牌----------------------------
            bool isgetcdsWithoutCompare = false;//标记是不是在自己出动出牌时做出的智能选牌

            int[] mayOutCds      = null;
            bool  selCdshasLaizi = PokerRuleUtil.CheckHaslz(selectedCds);

            if (!selCdshasLaizi && _onoffIchosecCds)
            {
                if (_lastOutData.GetInt(RequestKey.KeySeat) == App.GetGameData <GlobalData>().GetSelfSeat)
                {
                    mayOutCds = _checkCardTool.GetcdsWithOutCompare(selectedCds, HdCdsListTemp.ToArray());
                    isgetcdsWithoutCompare = true;
                }
                else
                {
                    //DDzUtil.ActiveBtn(BuYaoBtn, DisBuYaoBtn);
                    mayOutCds = _checkCardTool.ChkCanoutCdListWithLastCdList(selectedCds,
                                                                             _cardManager.GetTishiGroupDic, lastOutCds);
                }
            }
            //---------------------------------------------------------------------------------------end


            /*            //---start---------------使智能选牌出了相同的牌型,不重复执行-----------------------
             *          var haschosemayOutCds = DDzUtil.IsTwoArrayEqual(HdCdsCtrl.SortCds(_mayoutCdsTemp), HdCdsCtrl.SortCds(mayOutCds));
             *          _mayoutCdsTemp = mayOutCds;
             *          //如果上次智能选牌和本次相同,则直接取消一次智能选牌
             *          if (haschosemayOutCds)
             *          {
             *              mayOutCds = null;
             *          }
             *          //----------------------------------------------------------------------------------end*/



            if (mayOutCds == null || mayOutCds.Length == 0)
            {
                bool isMatch;

                //如果_lastOutData不是自己出牌
                if (_lastOutData.GetInt(RequestKey.KeySeat) != App.GetGameData <GlobalData>().GetSelfSeat)
                {
                    var lastoutcds = new List <int>();
                    lastoutcds.AddRange(lastOutCds);
                    var cardTypeDic = _cardManager.CheckCanGuanCds(selectedCds, selCdshasLaizi, lastoutcds.ToArray());
                    isMatch = cardTypeDic != null && cardTypeDic.Count > 0;
                }
                else
                {
                    var cardTypeDic = _cardManager.CheckCanGuanCds(selectedCds, selCdshasLaizi, null);
                    isMatch = cardTypeDic != null && cardTypeDic.Count > 0;
                }

                //Debug.LogError("isMatch: " + isMatch);
                if (isMatch)
                {
                    HdCdctrlInstance.UpCdList(selectedCds);
                }
                else
                {
                    DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn);
                    return;
                }
            }
            else
            {
                if (!ChooseMayOutCards(mayOutCds, selectedCds))
                {
                    DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn);
                    return;
                }
            }

            FinalOutCdsCheck(isgetcdsWithoutCompare);
        }