示例#1
0
 private void CreateItems(GangStruct card, eMJInstructionsType _type)
 {
     if (card == null || card.cards == null)
     {
         return;
     }
     if (_type == eMJInstructionsType.GANG)     //杠
     {
         if (card.gangType == eGangType.ANGANG) //暗杠
         {
             InitAngang(mCardGang, card.cards[0]);
         }
         else
         {
             InitPengItems(mCardGang, card.cards[0], card.cards[0], card.cards[0], card.cards[0]);
         }
     }
     else
     {
         int len = card.cards.Count;
         if (len == 3)
         {
             InitPengItems(mThreeLie, card.cards[0], card.cards[1], card.cards[2]);
         }
         else if (len == 4)
         {
             InitPengItems(mCardGang, card.cards[0], card.cards[1], card.cards[2], card.cards[3]);
         }
     }
 }
示例#2
0
 /// <summary>
 /// 设置杠牌
 /// </summary>
 /// <param name="_type"></param>
 /// <param name="myseatid"></param>
 /// <param name="cards"></param>
 /// <param name="playerPosType"></param>
 public void SetGangNum(eMJInstructionsType _type, int myseatid, GangStruct cards, PlayerPosType playerPosType)
 {
     SetArrowShow(false);
     mOtherAngang.SetActive(false);
     if (cards.cards.Count == 1)
     {
         SetNum(_type, cards.cards[0], cards.cards[0], cards.cards[0], cards.cards[0]);
     }
     else if (cards.cards.Count < 4)
     {
         SetNum(_type, cards.cards[0], cards.cards[1], cards.cards[2]);
     }
     else
     {
         SetNum(_type, cards.cards[0], cards.cards[1], cards.cards[2], cards.cards[3]);
     }
     if (_type == eMJInstructionsType.GANG && (cards.gangType == eGangType.DIANGANG || cards.gangType == eGangType.WANGANG))//普通杠
     {
         if (cards.otherSeatId != null && cards.otherSeatId != myseatid && cards.otherSeatId != 0)
         {
             SetArrowPos(myseatid, cards.otherSeatId, 4);
         }
     }
     if (_type == eMJInstructionsType.GANG && cards.gangType == eGangType.ANGANG)//暗杠
     {
         SetAnGang(playerPosType);
     }
 }
示例#3
0
    private GangStruct AddGangCard(ref List <GangStruct> mycard, MJoptInfoData data, int lastoutcard)
    {
        //我牌里面加一组
        if (mycard == null)
        {
            mycard = new List <GangStruct>();
        }
        GangStruct chicard = new GangStruct();

        chicard.cards       = new List <int>();
        chicard.otherSeatId = data.otherSeatId;
        switch (data.type)
        {
        case (int)eGangType.ANGANG:
            chicard.gangType = eGangType.ANGANG;
            break;

        case (int)eGangType.DIANGANG:
            chicard.gangType = eGangType.DIANGANG;
            break;

        case (int)eGangType.WANGANG:
            chicard.gangType = eGangType.WANGANG;
            break;
        }

        if (mHandCard != null && mHandCard.currCard > 0)//摸起来的牌加到手牌中并且去掉摸起来的牌
        {
            mHandCard.cards.Add(mHandCard.currCard);
            mHandCard.currCard = 0;
        }
        else if (mOtherCard != null && mOtherCard.isHasCurrCard)
        {
            mOtherCard.cardsNum     += 1;
            mOtherCard.isHasCurrCard = false;
        }
        //手牌中减去杠牌
        if (data.ins == eMJInstructionsType.GANG)
        {
            /* int len = 3;
             * if (data.type== (int)eGangType.ANGANG)
             * {
             *   len = 4;
             * }
             *
             */

            int len = 3;
            if (data.otherSeatId == mPlayerInfo.seatId || data.otherSeatId == 0) //暗杠
            {
                if (mPlayerInfo.pengList != null)                                //如果是先碰的牌再杠
                {
                    PengStruct card = mPlayerInfo.pengList.Find(o => o.cards[0] == data.cards[0]);
                    if (card != null)
                    {
                        mPlayerInfo.pengList.Remove(card);
                        len = 1;
                    }
                    else
                    {
                        len = 4;
                    }
                }
                else
                {
                    len = 4;
                }
            }
            else//别人打来杠
            {
                len = 3;
            }
            if (mHandCard != null && mHandCard.currCard == data.cards[0])//如果摸起来的牌也是杠牌要去掉
            {
                mHandCard.currCard = 0;
            }
            for (int i = 0; i < len; i++)
            {
                if (mHandCard != null && data.seatId == MJGameModel.Inst.mMySeatId)
                {
                    if (mHandCard.cards.Contains(data.cards[0]))
                    {
                        mHandCard.cards.Remove(data.cards[0]);
                    }
                    else
                    {
                        if (mHandCard.currCard == data.cards[0])
                        {
                            mHandCard.currCard = 0;
                        }
                    }
                }
                else
                {
                    mOtherCard.cardsNum--;
                }
            }
            chicard.cards.Add(data.cards[0]);
        }
        else if (data.ins == eMJInstructionsType.PENG)
        {
            int len = 2;
            for (int i = 0; i < len; i++)
            {
                if (mHandCard != null)
                {
                    if (data.cards.Count == 1)
                    {
                        mHandCard.cards.Remove(data.cards[0]);
                    }
                    else
                    {
                        mHandCard.cards.Remove(data.cards[i]);
                    }
                }
                else
                {
                    mOtherCard.cardsNum--;
                }
            }
            chicard.cards.Add(data.cards[0]);
        }
        else if (data.ins == eMJInstructionsType.CHI)
        {
            int len = data.cards.Count;
            for (int i = 0; i < len; i++)
            {
                if (lastoutcard != data.cards[i])
                {
                    if (mHandCard != null)
                    {
                        if (data.cards.Count == 1)
                        {
                            mHandCard.cards.Remove(data.cards[0]);
                        }
                        else if (data.cards[i] != lastoutcard)
                        {
                            mHandCard.cards.Remove(data.cards[i]);
                        }
                    }
                    else
                    {
                        mOtherCard.cardsNum--;
                    }
                }
                //chicard.type = data.type;
                chicard.cards.Add(data.cards[i]);
            }
        }
        else
        {
            for (int i = 0; i < data.cards.Count; i++)
            {
                if (mHandCard != null)
                {
                    if (mHandCard.cards.Contains(data.cards[i]))
                    {
                        mHandCard.cards.Remove(data.cards[i]);
                    }
                    else
                    {
                        if (mHandCard.currCard == data.cards[i])
                        {
                            mHandCard.currCard = 0;
                        }
                    }
                }
                else
                {
                    mOtherCard.cardsNum--;
                }
                chicard.cards.Add(data.cards[i]);
            }
        }
        if (mHandCard != null)
        {
            //mHandCard.cards.Sort();
            mycard.Add(chicard);
        }
        return(chicard);
    }
示例#4
0
    private GangStruct AddGangCard(ref List <GangStruct> mycard, MJoptInfoData data, int lastoutcard)
    {
        //我牌里面加一组
        if (mycard == null)
        {
            mycard = new List <GangStruct>();
        }
        GangStruct chicard = new GangStruct();

        chicard.cards       = new List <int>();
        chicard.otherSeatId = data.otherSeatId;
        switch (data.type)
        {
        case (int)eGangType.ANGANG:
            chicard.gangType = eGangType.ANGANG;
            break;

        case (int)eGangType.DIANGANG:
            chicard.gangType = eGangType.DIANGANG;
            break;

        case (int)eGangType.WANGANG:
            chicard.gangType = eGangType.WANGANG;
            break;
        }

        if (currCard > 0)//摸起来的牌加到手牌中并且去掉摸起来的牌
        {
            handList.Add(currCard);
            currCard = 0;
        }
        else if (isHasCurrCard)
        {
            cardNum      += 1;
            isHasCurrCard = false;
        }
        //手牌中减去杠牌
        if (data.ins == eMJInstructionsType.GANG)
        {
            int len = 3;
            if (data.otherSeatId == seatId || data.otherSeatId == 0) //暗杠
            {
                if (pengList != null)                                //如果是先碰的牌再杠
                {
                    PengStruct card = pengList.Find(o => o.cards[0] == data.cards[0]);
                    if (card != null)
                    {
                        pengList.Remove(card);
                        len = 1;
                    }
                    else
                    {
                        len = 4;
                    }
                }
                else
                {
                    len = 4;
                }
            }
            else//别人打来杠
            {
                len = 3;
            }
            if (handList != null && currCard == data.cards[0])//如果摸起来的牌也是杠牌要去掉
            {
                currCard = 0;
            }
            for (int i = 0; i < len; i++)
            {
                if (handList != null)
                {
                    if (handList.Contains(data.cards[0]))
                    {
                        handList.Remove(data.cards[0]);
                    }
                    else
                    {
                        if (currCard == data.cards[0])
                        {
                            currCard = 0;
                        }
                    }
                }
                else
                {
                    cardNum--;
                }
            }
            chicard.cards.Add(data.cards[0]);
        }
        else if (data.ins == eMJInstructionsType.PENG)
        {
            int len = 2;
            for (int i = 0; i < len; i++)
            {
                if (handList != null)
                {
                    if (data.cards.Count == 1)
                    {
                        handList.Remove(data.cards[0]);
                    }
                    else
                    {
                        handList.Remove(data.cards[i]);
                    }
                }
                else
                {
                    cardNum--;
                }
            }
            chicard.cards.Add(data.cards[0]);
        }
        else if (data.ins == eMJInstructionsType.CHI)
        {
            int len = data.cards.Count;
            for (int i = 0; i < len; i++)
            {
                if (lastoutcard != data.cards[i])
                {
                    if (handList != null)
                    {
                        if (data.cards.Count == 1)
                        {
                            handList.Remove(data.cards[0]);
                        }
                        else if (data.cards[i] != lastoutcard)
                        {
                            handList.Remove(data.cards[i]);
                        }
                    }
                    else
                    {
                        cardNum--;
                    }
                }
                chicard.cards.Add(data.cards[i]);
            }
        }
        else
        {
            for (int i = 0; i < data.cards.Count; i++)
            {
                if (handList != null)
                {
                    if (handList.Contains(data.cards[i]))
                    {
                        handList.Remove(data.cards[i]);
                    }
                    else
                    {
                        if (currCard == data.cards[i])
                        {
                            currCard = 0;
                        }
                    }
                }
                else
                {
                    cardNum--;
                }
                chicard.cards.Add(data.cards[i]);
            }
        }
        mycard.Add(chicard);
        return(chicard);
    }