Exemple #1
0
    public void RevMsgGS2CUpdateCardInfoAfterExchange(int pid, byte[] msgBuf, int msgSize)
    {
        Debug.Log("==>> RevMsgGS2CUpdateCardInfoAfterExchange");
        Stream stream = new MemoryStream(msgBuf);

        pb.GS2CUpdateCardInfoAfterExchange msg = ProtoBuf.Serializer.Deserialize <pb.GS2CUpdateCardInfoAfterExchange>(stream);
        BattleManager.Instance.UpdateExchangeCardInfo(msg);
    }
Exemple #2
0
    public void UpdateExchangeCardInfo(pb.GS2CUpdateCardInfoAfterExchange msg)
    {
        //只处理自己交换牌
        List <pb.CardInfo> selfNewCardList = new List <pb.CardInfo>();

        for (int i = 0; i < msg.cardList.Count; i++)
        {
            if (msg.cardList[i].playerId == Player.Instance.PlayerInfo.OID)
            {
                selfNewCardList.Add(msg.cardList[i]);
            }
        }
        Debug.Log("After exchange card, self card count is " + selfNewCardList.Count);

        List <int> _selfExchangeCardOid = new List <int>();

        for (int i = 0; i < _playerPaiInfoList.Count; i++)
        {
            int playerId = _playerPaiInfoList[i].PlayerInfo.OID;
            if (playerId == Player.Instance.PlayerInfo.OID)
            {
                //自己的牌将交换牌区分出来,用以动画表现
                _playerPaiInfoList[i].RemoveExchangeCard();
                List <Pai> curPaiList = _playerPaiInfoList[i].GetPaiListByStatus(PaiStatus.InHand);
                Debug.Log("self has " + curPaiList.Count + " inhand cards.");
                for (int n = 0; n < selfNewCardList.Count; n++)
                {
                    pb.CardInfo curCard = selfNewCardList[n];
                    bool        isFind  = false;
                    for (int j = 0; j < curPaiList.Count; j++)
                    {
                        if (curPaiList[j].OID == curCard.CardOid)
                        {
                            isFind = true;
                            break;
                        }
                    }
                    if (!isFind)
                    {
                        Pai pai = new Pai();
                        pai.OID      = curCard.CardOid;
                        pai.Id       = curCard.CardId;
                        pai.Status   = PaiStatus.Exchange;
                        pai.PlayerID = curCard.playerId;
                        _playerPaiInfoList[i].GetPaiList().Add(pai);
                    }
                }
                Debug.Log("self has " + _playerPaiInfoList[i].GetPaiList().Count + " cards.");
            }
            else
            {
                // 其他人直接更新所有牌
                _playerPaiInfoList[i].ClearPai();
                for (int j = 0; j < msg.cardList.Count; j++)
                {
                    if (playerId == msg.cardList[j].playerId)
                    {
                        _playerPaiInfoList[i].AddPai(msg.cardList[j]);
                    }
                }
                Debug.Log("other has " + _playerPaiInfoList[i].GetPaiList().Count + " cards.");
            }
        }
        EventDispatcher.TriggerEvent <pb.ExchangeType>(EventDefine.UpdateCardInfoAfterExchange, msg.type);
    }