コード例 #1
0
    public void RevMsgGS2CUpdateRoomInfo(int pid, byte[] msgBuf, int msgSize)
    {
        Debug.Log("==>> RevMsgGS2CUpdateRoomInfo");
        Stream stream = new MemoryStream(msgBuf);

        pb.GS2CUpdateRoomInfo msg = ProtoBuf.Serializer.Deserialize <pb.GS2CUpdateRoomInfo>(stream);
        BattleManager.Instance.UpdatePlayerInfo(msg);
    }
コード例 #2
0
    public void UpdatePlayerInfo(pb.GS2CUpdateRoomInfo msg)
    {
        Debug.Log("UpdatePlayerInfo=> status:" + msg.status.ToString() + ", player count:" + msg.player.Count);
        switch (msg.status)
        {
        case pb.GS2CUpdateRoomInfo.Status.ADD:
            for (int i = 0; i < msg.player.Count; i++)
            {
                if (getPlayerIndexInList(msg.player[i].player.oid) != -1)
                {
                    Debug.LogError("List has contained the player [" + msg.player[i].player.nickName + "], don't need add.");
                }
                else
                {
                    SideInfo info = new SideInfo();
                    info.UpdateBattlePlayerInfo(msg.player[i]);
                    _playerPaiInfoList.Add(info);
                    Debug.Log("add player to room, oid=" + info.PlayerInfo.OID + ", side=" + msg.player[i].side);
                    EventDispatcher.TriggerEvent(EventDefine.UpdateRoleInRoom);
                }
            }
            break;

        case pb.GS2CUpdateRoomInfo.Status.REMOVE:
            for (int i = 0; i < msg.player.Count; i++)
            {
                int index = getPlayerIndexInList(msg.player[i].player.oid);
                if (index != -1)
                {
                    _playerPaiInfoList.RemoveAt(index);
                }
                else
                {
                    Debug.LogError("Dict doesn't contain the player [" + msg.player[i].player.nickName + "], can't remove.");
                }
            }
            break;

        case pb.GS2CUpdateRoomInfo.Status.UPDATE:
            for (int i = 0; i < msg.player.Count; i++)
            {
                int index = getPlayerIndexInList(msg.player[i].player.oid);
                if (index != -1)
                {
                    _playerPaiInfoList[index].UpdateBattlePlayerInfo(msg.player[i]);
                }
                else
                {
                    Debug.LogError("Dict doesn't contain the player [" + msg.player[i].player.nickName + "], can't update.");
                }
            }
            break;

        default:
            break;
        }
    }