Ejemplo n.º 1
0
 public void UpdatePai(Pai origInfo, pb.CardInfo newInfo)
 {
     origInfo.OID         = newInfo.CardOid;
     origInfo.Id          = newInfo.CardId;
     origInfo.Status      = getPaiStatus(newInfo.Status);
     origInfo.PlayerID    = newInfo.playerId;
     origInfo.IsFromOther = newInfo.fromOther;
 }
Ejemplo n.º 2
0
    public void AddPai(pb.CardInfo card)
    {
        Pai pai = new Pai();

        pai.OID         = card.CardOid;
        pai.Id          = card.CardId;
        pai.Status      = getPaiStatus(card.Status);
        pai.PlayerID    = card.playerId;
        pai.IsFromOther = card.fromOther;
        _paiList.Add(pai);
    }
Ejemplo n.º 3
0
 public void SendMsgC2GSExchangeCard(List <Pai> exchangeList)
 {
     Debug.Log("SendMsgC2GSExchangeCard==>> [" + exchangeList.Count + "]");
     pb.C2GSExchangeCard msg = new pb.C2GSExchangeCard();
     for (int i = 0; i < exchangeList.Count; i++)
     {
         pb.CardInfo card = new pb.CardInfo();
         card.CardOid  = exchangeList[i].OID;
         card.CardId   = exchangeList[i].Id;
         card.playerId = exchangeList[i].PlayerID;
         card.Status   = pb.CardStatus.inHand;
         msg.cardList.Add(card);
     }
     NetworkManager.Instance.SendToGS((UInt16)MsgDef.C2GSExchangeCard, msg);
 }
Ejemplo n.º 4
0
 public void TurnToNextPlayer(int playerOid, pb.CardInfo drawnCard, pb.TurnSwitchType type)
 {
     Debug.Log("turn to next:" + playerOid + ", type=" + type.ToString());
     if (drawnCard != null)
     {
         Debug.Log("draw new card:" + drawnCard.CardOid);
         BattleManager.Instance.CurTurnDrawnCardOid = drawnCard.CardOid;
     }
     _curPlaySide = GetSideByPlayerOID(playerOid);
     for (int i = 0; i < _playerPaiInfoList.Count; i++)
     {
         if (_playerPaiInfoList[i].PlayerInfo.OID == playerOid && drawnCard != null)
         {
             _playerPaiInfoList[i].AddPai(drawnCard);
         }
     }
     EventDispatcher.TriggerEvent <pb.BattleSide, pb.CardInfo, pb.TurnSwitchType>(EventDefine.TurnToPlayer, _curPlaySide, drawnCard, type);
 }
Ejemplo n.º 5
0
 public void PrepareGameStart(pb.GS2CBattleStart msg)
 {
     for (int i = 0; i < msg.cardList.Count; i++)
     {
         pb.CardInfo card = msg.cardList[i];
         for (int j = 0; j < _playerPaiInfoList.Count; j++)
         {
             if (_playerPaiInfoList[j].PlayerInfo.OID == card.playerId)
             {
                 _playerPaiInfoList[j].AddPai(card);
             }
         }
     }
     _dealerId    = msg.dealerId;
     _curPlaySide = GetSideByPlayerOID(_dealerId);
     Debug.Log("_dealerId=" + _dealerId + ", side=" + _curPlaySide.ToString());
     EventDispatcher.TriggerEvent(EventDefine.PlayGamePrepareAni);
 }
Ejemplo n.º 6
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);
    }