/// <summary> /// 显示按钮,并disable所有按钮 /// </summary> private void DisableAllBtns() { //DDzUtil.DisableBtn(BuYaoBtn, DisBuYaoBtn); DDzUtil.DisableBtn(TiShiBtn, DisTiShiBtn); DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn); var hdcdSplitGp = new CdSplitStruct(HdCdsListTemp.ToArray()); //如果含有炸弹则跳过 if (hdcdSplitGp.FourCds.Count < 1) { var canOutType = CheckCanOutCdsOneTime(hdcdSplitGp); //防止发送消息不成功,直接点亮出牌按钮,让玩家有再次发送的机会 if (canOutType != CardType.None && canOutType != CardType.Exception) { HdCdctrlInstance.UpAllHandCds(); DDzUtil.ActiveBtn(ChuPaiBtn, DisChuPaiBtn); return; } } var args = new HdCdCtrlEvtArgs(HdCdctrlInstance.GetUpCdList().ToArray()); OnHdCdsCtrlEvent(null, args); _onoffIchosecCds = true; }
//------------------------------------------------------------------------------------------------ /// <summary> /// 当上一次玩家出牌不是自己时 /// </summary> /// <param name="lastOutData">最后一次出牌的信息</param> /// <param name="isRejoin">标记是否是重连进入的</param> private void OnNotSelfOutCds(ISFSObject lastOutData, bool isRejoin = false) { //DDzUtil.ActiveBtn(BuYaoBtn, DisBuYaoBtn); DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn); //玩家剩余最后4张牌,牌型三带一,最后一次出牌信息三带二,特殊改为玩家三带二计算(特殊情况) var lastcdType = CardType.None; lastcdType = PokerRuleUtil.GetCdsType(lastOutData.GetIntArray(RequestKey.KeyCards)); if (HdCdsListTemp.ToArray().Length == 4 && lastcdType == CardType.C32) { var sortedLastOutCd = PokerRuleUtil.GetSortedValues(HdCdsListTemp.ToArray()); var dictoNum = new Dictionary <int, int>(); foreach (var cd in sortedLastOutCd) { if (!dictoNum.ContainsKey(cd)) { dictoNum[cd] = 1; continue; } dictoNum[cd]++; } var dictoNumTwo = dictoNum; foreach (var cd in dictoNum.Keys.Where(cd => dictoNum[cd] == 1)) { dictoNumTwo[cd]++; break; } List <int> TempHdCdsListTemp = new List <int>(); foreach (var item in dictoNumTwo) { for (int i = 0; i < item.Value; i++) { TempHdCdsListTemp.Add(item.Key); } } endchupaiV(isRejoin, TempHdCdsListTemp, lastOutData); } else { endchupaiV(isRejoin, HdCdsListTemp, lastOutData); } var args = new HdCdCtrlEvtArgs(HdCdctrlInstance.GetUpCdList().ToArray()); OnHdCdsCtrlEvent(null, args); _onoffIchosecCds = true; }
/// <summary> /// 出牌 /// </summary> /// <param name="cards"></param> void SelectCards(int[] cards) { var args = new HdCdCtrlEvtArgs(cards); Facade.EventCenter.DispatchEvent(GlobalConstKey.KeyHdCds, args); }
/// <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 }
/// <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); }