コード例 #1
0
        /// <summary>
        /// 逐行展示手牌
        /// </summary>
        /// <param name="line">行数</param>
        /// <param name="matchInfo"></param>
        public void ShowHandPoker(int line, UserMatchInfo matchInfo)
        {
            int beginIndex = 0;
            int count      = 0;

            InitRange(line, ref beginIndex, ref count);

            List <int> cardValueList = matchInfo.Cards.GetRange(beginIndex, count);

            cardValueList = HelpLz.SortLineList(cardValueList, (CardType)matchInfo.DunTypeList[line]);

            //设置显示手牌
            for (int i = 0; i < UserCardList.Count; i++)
            {
                GameObject obj = UserCardList[i];
                if (i >= beginIndex && i < beginIndex + count)
                {
                    obj.transform.localScale = Vector3.one * (HandCardsTargetPosPar.Scale + .1f);
                    PokerCard card = obj.GetComponent <PokerCard>();
                    card.SetCardDepth(100 + i * 2);
                    card.SetCardId(cardValueList[i - beginIndex]);
                    card.SetCardFront();
                }
                else
                {
                    obj.transform.localScale = Vector3.one * HandCardsTargetPosPar.Scale;
                    obj.GetComponent <PokerCard>().SetCardDepth(i * 2);
                }
            }
        }
コード例 #2
0
ファイル: ChoiseWay0.cs プロジェクト: narakai/chessgame
        public override void ShowChoiseView(ISFSObject cardData)
        {
            base.ShowChoiseView(cardData);
            InitPokerList();        //初始化左侧的牌
            RepositionCards();      //将左侧的牌排列成三行

            gameObject.SetActive(true);

            int[] array = cardData.GetIntArray("cards");

            HelpLz     help      = new HelpLz();
            List <int> pokerList = array.ToList();

            Resort(pokerList);
            List <HelpLz.PlayerDuns> pd = help.getPlayerDuns(pokerList);

            while (pd.Count > 0 && pd[0].Duns[0] == null)
            {
                pd.Remove(pd[0]);
            }

            int itemCount = pd.Count > 3 ? 3 : pd.Count;

            //初始化数据
            for (int i = 0; i < itemCount; i++)
            {
                ChoiseItem item = _choiseItems[i];
                item.gameObject.SetActive(true);
                if ((int)pd[i].SpecialType - (int)CardType.none >= 0)   //特殊牌型,不用显示每行牌型
                {
                    item.SpecialObj.SetActive(true);
                    item.NormalObj.SetActive(false);
                    item.Special = (int)pd[i].SpecialType;
                    item.SpecialSprite.spriteName = pd[i].SpecialType.ToString();
                    item.SpecialSprite.MakePixelPerfect();
                    item.SetChoiseItem(pd[i].Duns);
                }
                else    //普通牌型,要显示每组牌的牌型
                {
                    item.SpecialObj.SetActive(false);
                    item.NormalObj.SetActive(true);

                    item.SetChoiseItem(pd[i].Duns);
                }
            }
            OnClickPlane(_choiseItems[0]);
        }
コード例 #3
0
ファイル: ChoiseWay0.cs プロジェクト: narakai/chessgame
        public void OnClickOkBtn()
        {
            ISFSObject obj      = new SFSObject();
            ISFSArray  arr      = new SFSArray();
            string     errorMsg = string.Empty;

            if (_lastChoiseItem != null && _lastChoiseItem.Special > 0)
            {
                obj.PutInt("special", _lastChoiseItem.Special);
            }
            else
            {
                if (!NoDaoShui(_lastList, ref errorMsg))
                {
                    YxMessageBox.Show(new YxMessageBoxData()
                    {
                        Msg     = errorMsg,
                        Delayed = 3,
                    });
                    YxDebug.Log("不能倒水");
                    return;
                }
            }

            int beginIndex = 0;

            for (int i = 0; i < 3; i++)
            {
                int        count    = i == 0 ? 3 : 5;
                List <int> tempList = _lastList.GetRange(beginIndex, count);
                ISFSObject arrItem  = new SFSObject();
                arrItem.PutInt("type", (int)CheckCardType(tempList, i));
                HelpLz.SortList(tempList);
                arrItem.PutIntArray("cards", tempList.ToArray());
                arr.AddSFSObject(arrItem);
                beginIndex += count;
            }

            obj.PutSFSArray("duninfo", arr);

            obj.PutInt("type", GameRequestType.FinishChoise);

            App.GetRServer <SssjpGameServer>().SendGameRequest(obj);
        }
コード例 #4
0
ファイル: ChoiseLine1.cs プロジェクト: narakai/chessgame
        /// <summary>
        /// 设置牌
        /// </summary>
        /// <param name="cardValList"></param>
        public void SetLineCardsVal(List <int> cardValList)
        {
            cardValList = HelpLz.SortLineList(cardValList, _lineInfo.CardType);

            int count = cardValList.Count;

            if (count != CardList.Count)
            {
                return;
            }
            for (int i = 0; i < count; i++)
            {
                var card = CardList[i];
                card.SetCardId(cardValList[i]);
                card.SetCardFront();
                card.gameObject.SetActive(true);
            }
            _lineInfo.Dun.Cards = cardValList;
        }
コード例 #5
0
ファイル: ChoiseWay1.cs プロジェクト: narakai/chessgame
        public override void ShowChoiseView(ISFSObject cardData)
        {
            base.ShowChoiseView(cardData);

            InitPokerList();

            gameObject.SetActive(true);

            int[] cardArray = cardData.GetIntArray("cards");

            _cardValList = cardArray.ToList();
            HelpLz.SortList(_cardValList);

            HelpLz help = new HelpLz();
            List <HelpLz.PlayerDuns> pd = help.getPlayerDuns(_cardValList);

            //初始化手牌,待删
            for (int i = 0; i < CardsList.Count; i++)
            {
                CardsList[i].SetCardId(_cardValList[i]);
                CardsList[i].SetCardFront();
            }

            RespositionCards();//初始化手牌位置

            if (SpecialBtn != null)
            {
                if (pd.Count > 0 && pd[0].SpecialType > CardType.none)
                {
                    _specialDuns = pd[0];
                    SpecialBtn.gameObject.SetActive(true);
                }
                else
                {
                    _specialDuns = null;
                    SpecialBtn.gameObject.SetActive(false);
                }
            }

            SetChoiseView(_cardValList);
        }
コード例 #6
0
ファイル: ChoiseWay1.cs プロジェクト: narakai/chessgame
        public void OnClickOkBtn()
        {
            ISFSObject obj = new SFSObject();
            ISFSArray  arr = new SFSArray();

            if (_selectInfo != null && _selectInfo.CardType > CardType.none)
            {
                obj.PutInt("special", (int)_selectInfo.CardType);
            }
            else
            {
                string errorMsg = string.Empty;
                if (CheckIsDaoShui(ref errorMsg))
                {
                    YxMessageBox.Show(new YxMessageBoxData()
                    {
                        Msg     = errorMsg,
                        Delayed = 3,
                    });
                    YxDebug.Log("不能倒水");
                    return;
                }
            }

            for (int i = 0; i < 3; i++)
            {
                var        lineInfo = Lines[i].LineInfo;
                ISFSObject arrItem  = new SFSObject();
                arrItem.PutInt("type", (int)lineInfo.CardType);
                var tempList = lineInfo.Dun.Cards;
                HelpLz.SortList(tempList, false);
                arrItem.PutIntArray("cards", tempList.ToArray());
                arr.AddSFSObject(arrItem);
            }
            obj.PutSFSArray("duninfo", arr);

            //发送到服务器
            obj.PutInt("type", GameRequestType.FinishChoise);
            App.GetRServer <SssjpGameServer>().SendGameRequest(obj);
        }
コード例 #7
0
ファイル: ChoiseWay1.cs プロジェクト: narakai/chessgame
        /// <summary>
        /// 获取按钮状态位,同时初始化字典
        /// </summary>
        /// <param name="pokerList"></param>
        /// <returns></returns>
        private int GetBtnState(List <int> pokerList)
        {
            if (pokerList.Count < 3)
            {
                return(0);
            }

            int btnState = 0;


            CnList cnList = new CnList(pokerList);
            VnList vnList = new VnList(pokerList);

            CnList cn5 = cnList.GetMoreThan(5, true, true);     //同花色5个以上
            VnList vn2 = vnList.GetMoreThan(2, true);           //同数值的2个以上

            _cardTypeDic.Clear();

            //同花顺,128
            if (cn5.Count > 0)
            {
                foreach (var cnItem in cn5)
                {
                    if (HaveAndAdd(cnItem.Cards, CardType.tonghuashun, CardType.tonghuashun))
                    {
                        btnState |= GetStateVal(CardType.tonghuashun);
                    }
                }
            }

            //铁支
            VnList vn4 = vnList.GetEqual(4, true);

            if (vn4.Count > 0)
            {
                foreach (var item in vn4)
                {
                    SssDun dun = new SssDun
                    {
                        CardType = CardType.tiezhi,
                        Cards    = item.Cards
                    };
                    AddToDic(_cardTypeDic, CardType.tiezhi, dun);
                }
                btnState |= GetStateVal(CardType.tiezhi);
            }

            VnList vn3 = vnList.GetMoreThan(3, true);

            //葫芦
            if (vn3.Count > 0 && vn2.Count > 0)
            {
                foreach (var item3 in vn3)
                {
                    foreach (var item2 in vn2)
                    {
                        if (item3.Val == item2.Val)
                        {
                            continue;
                        }

                        AddListToDic(CardType.hulu, _cardTypeDic, item3.Cards.GetRange(0, 3), item2.Cards.GetRange(0, 2));

                        btnState |= GetStateVal(CardType.hulu);
                    }
                }
            }

            //同花
            if (cn5.Count > 0)
            {
                btnState = cn5.Where(item => HaveAndAdd(item.Cards, CardType.tonghua))
                           .Aggregate(btnState, (current, item) => current | GetStateVal(CardType.tonghua));
            }

            //顺子
            {
                List <SssDun> dunList = new List <SssDun>();
                HelpLz        help    = new HelpLz();
                if (help.CheckShunZi(pokerList, dunList, 5, false))
                {
                    foreach (var dun in dunList)
                    {
                        AddToDic(_cardTypeDic, CardType.shunzi, dun);
                    }
                    btnState |= GetStateVal(CardType.shunzi);
                }
            }

            //三条
            if (vn3.Count > 0)
            {
                int count = vn3.Count;
                for (int i = 0; i < count; i++)
                {
                    AddListToDic(CardType.santiao, _cardTypeDic, vn3[i].Cards.GetRange(0, 3));
                }
                btnState |= GetStateVal(CardType.santiao);
            }

            //两对
            if (vn2.Count > 1)
            {
                int count = vn2.Count;
                for (int i = 0; i < count; i++)
                {
                    int vn2Vi = vn2[i].Val;
                    for (int j = i; j < count; j++)
                    {
                        int vn2Vj = vn2[j].Val;
                        if (vn2Vi == vn2Vj)
                        {
                            continue;
                        }
                        AddListToDic(CardType.liangdui, _cardTypeDic, vn2[i].Cards.GetRange(0, 2),
                                     vn2[j].Cards.GetRange(0, 2));
                        btnState |= GetStateVal(CardType.liangdui);
                    }
                }
            }

            //对子
            if (vn2.Count > 0)
            {
                int count = vn2.Count;
                for (int i = 0; i < count; i++)
                {
                    AddListToDic(CardType.yidui, _cardTypeDic, vn2[i].Cards.GetRange(0, 2));
                }
                btnState |= GetStateVal(CardType.yidui);
            }

            return(btnState);
        }
コード例 #8
0
ファイル: ChoiseWay1.cs プロジェクト: narakai/chessgame
 /// <summary>
 /// 根据牌面值对列表进行排序
 /// </summary>
 /// <param name="list">要排序的牌列表</param>
 /// <param name="up">是否是升序排列</param>
 void Resort(List <int> list, bool up = true)
 {
     HelpLz.SortList(list, up);
 }
コード例 #9
0
ファイル: ChoiseWay1.cs プロジェクト: narakai/chessgame
        /// <summary>
        /// 检测牌型
        /// </summary>
        /// <param name="cards">牌</param>
        /// <param name="line">第几行,不为0时,排数是五张</param>
        /// <returns></returns>
        public CardType CheckCardType(List <int> cards, int line = 2)
        {
            //除去可能产生的不必要的信息
            cards = cards.GetRange(0, line == 0 ? 3 : 5);

            //检测牌型
            bool       isTongHua   = line != 0;
            bool       isShunZi    = line != 0;
            int        samecount   = 1;
            List <int> sameNumList = new List <int>();

            Resort(cards);
            int color = HelpLz.GetColor(cards[0]);
            int value = HelpLz.GetValue(cards[0]);

            for (int i = 1; i < cards.Count; i++)
            {
                int card = cards[i];
                if (card == 0)
                {
                    continue;
                }
                int cardColor = HelpLz.GetColor(card);
                int cardValue = HelpLz.GetValue(card);
                if (cardColor != color)
                {
                    isTongHua = false;
                }
                if (cardValue - value != 1)
                {
                    isShunZi = false;
                }

                if (cardValue == value)
                {
                    samecount++;
                }
                else
                {
                    if (samecount > 0)
                    {
                        sameNumList.Add(samecount);
                        samecount = 1;
                    }
                }

                value = cardValue;
            }
            sameNumList.Add(samecount);
            if (line == 0)
            {
                if (sameNumList.Count == 2)
                {
                    return(CardType.yidui);
                }
                if (sameNumList.Count == 1)
                {
                    return(CardType.santiao);
                }

                return(CardType.sanpai);
            }


            if (isTongHua && isShunZi)
            {
                return(CardType.tonghuashun);
            }
            if (isShunZi)
            {
                return(CardType.shunzi);
            }
            if (isTongHua)
            {
                return(CardType.tonghua);
            }
            if (sameNumList.Count > 0)
            {
                if (sameNumList.Count == 1)
                {
                    samecount = sameNumList[0];
                    if (samecount == 2)
                    {
                        return(CardType.yidui);
                    }
                    else if (samecount == 3)
                    {
                        return(CardType.santiao);
                    }
                    else if (samecount == 4)
                    {
                        return(CardType.tiezhi);
                    }
                }
                else if (sameNumList.Count == 2)
                {
                    samecount = sameNumList[0];
                    int samecount1 = sameNumList[1];
                    if ((samecount == 2 && samecount1 == 3) || (samecount == 3 && samecount1 == 2))
                    {
                        return(CardType.hulu);
                    }
                    else if (samecount == 4 || samecount1 == 4)
                    {
                        return(CardType.tiezhi);
                    }
                }
                else if (sameNumList.Count == 3)
                {
                    if (sameNumList.Any(item => item == 3))
                    {
                        return(CardType.santiao);
                    }
                    return(CardType.liangdui);
                }
                else if (sameNumList.Count == 4)
                {
                    return(CardType.yidui);
                }
            }

            return(CardType.sanpai);
        }
コード例 #10
0
ファイル: ChoiseWay0.cs プロジェクト: narakai/chessgame
 /// <summary>
 /// 根据牌面值对列表进行排序
 /// </summary>
 /// <param name="list">要排序的牌列表</param>
 /// <param name="mode">1为升序,-1为降序,默认升序</param>
 void Resort(List <int> list, int mode = 1)
 {
     list.Sort((x, y) => mode * HelpLz.GetValue(x).CompareTo(HelpLz.GetValue(y)));
 }