Exemple #1
0
    public static int getGameRoomPlayerCount(string gameRoomType)
    {
        int count = 0;

        for (int i = 0; i < PlayLogic_PVP.getInstance().getRoomList().Count; i++)
        {
            DDZ_RoomData tempRoom = PlayLogic_DDZ.getInstance().getRoomList()[i];
            if (tempRoom.m_gameRoomType.CompareTo(gameRoomType) == 0)
            {
                for (int j = 0; j < tempRoom.getPlayerDataList().Count; j++)
                {
                    ++count;
                }
            }
        }

        return(count);
    }
Exemple #2
0
    public static DDZ_RoomData getRoomByUid(string uid)
    {
        DDZ_RoomData room = null;

        for (int i = 0; i < PlayLogic_DDZ.getInstance().getRoomList().Count; i++)
        {
            List <DDZ_PlayerData> playerDataList = PlayLogic_DDZ.getInstance().getRoomList()[i].getPlayerDataList();

            for (int j = 0; j < playerDataList.Count; j++)
            {
                if (playerDataList[j].m_uid.CompareTo(uid) == 0)
                {
                    room = PlayLogic_DDZ.getInstance().getRoomList()[i];
                    return(room);
                }
            }
        }

        return(room);
    }
Exemple #3
0
    public static bool checkPlayerIsInRoom(string uid)
    {
        bool b = false;

        for (int i = 0; i < PlayLogic_DDZ.getInstance().getRoomList().Count; i++)
        {
            List <DDZ_PlayerData> playerDataList = PlayLogic_DDZ.getInstance().getRoomList()[i].getPlayerDataList();

            for (int j = 0; j < playerDataList.Count; j++)
            {
                if (playerDataList[j].m_uid.CompareTo(uid) == 0)
                {
                    b = true;
                    break;
                }
            }
        }

        return(b);
    }
Exemple #4
0
    public static DDZ_PlayerData getPlayerDataByConnId(IntPtr connId)
    {
        DDZ_PlayerData playerData = null;

        for (int i = 0; i < PlayLogic_DDZ.getInstance().getRoomList().Count; i++)
        {
            List <DDZ_PlayerData> playerDataList = PlayLogic_DDZ.getInstance().getRoomList()[i].getPlayerDataList();

            for (int j = 0; j < playerDataList.Count; j++)
            {
                if (playerDataList[j].m_connId == connId)
                {
                    playerData = playerDataList[j];

                    return(playerData);
                }
            }
        }

        return(playerData);
    }
    // 处理客户端的请求
    void doAskCilentReq(object obj)
    {
        ReceiveObj receiveObj = (ReceiveObj)obj;
        string     text       = receiveObj.m_data;

        // 日志
        {
            PlayerData playerData = GameUtil.getPlayerDataByConnId(receiveObj.m_connId);
            if (playerData != null)
            {
                RoomData room = GameUtil.getRoomByUid(playerData.m_uid);
                if (room != null)
                {
                    LogUtil.getInstance().writeRoomLog(room, "收到客户端消息:" + text);
                }
                else
                {
                    LogUtil.getInstance().addDebugLog("收到客户端消息:" + text);
                }
            }
            else
            {
                LogUtil.getInstance().addDebugLog("收到客户端消息:" + text);
            }
        }

        JObject jo;

        try
        {
            jo = JObject.Parse(text);
        }
        catch (JsonReaderException ex)
        {
            // 传过来的数据不是json格式的,一律不理
            // 日志
            {
                PlayerData playerData = GameUtil.getPlayerDataByConnId(receiveObj.m_connId);
                if (playerData != null)
                {
                    RoomData room = GameUtil.getRoomByUid(playerData.m_uid);
                    if (room != null)
                    {
                        LogUtil.getInstance().writeRoomLog(room, "客户端传来非json数据:" + text);
                    }
                    else
                    {
                        LogUtil.getInstance().addDebugLog("客户端传来非json数据:" + text);
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog("客户端传来非json数据:" + text);
                }
            }

            m_endStr = "";

            return;
        }

        if (jo.GetValue("tag") != null)
        {
            string tag = jo.GetValue("tag").ToString();

            // 休闲场相关
            if (tag.CompareTo(TLJCommon.Consts.Tag_XiuXianChang) == 0)
            {
                PlayLogic_Relax.getInstance().OnReceive(receiveObj.m_connId, text);
            }
            // 比赛场相关
            else if (tag.CompareTo(TLJCommon.Consts.Tag_JingJiChang) == 0)
            {
                PlayLogic_PVP.getInstance().OnReceive(receiveObj.m_connId, text);
            }
            // 获取pvp场次信息
            else if (tag.CompareTo(TLJCommon.Consts.Tag_GetPVPGameRoom) == 0)
            {
                NetRespond_GetPVPGameRoom.doAskCilentReq_GetPVPGameRoom(receiveObj.m_connId, text);
            }
            // 请求服务器在线玩家信息接口
            else if (tag.CompareTo(TLJCommon.Consts.Tag_OnlineInfo) == 0)
            {
                NetRespond_OnlineInfo.doAskCilentReq_OnlineInfo(receiveObj.m_connId, text);
            }
            // 使用buff
            else if (tag.CompareTo(TLJCommon.Consts.Tag_UseBuff) == 0)
            {
                NetRespond_UseBuff.doAskCilentReq_UseBuff(receiveObj.m_connId, text);
            }
            // 是否已经加入游戏
            else if (tag.CompareTo(TLJCommon.Consts.Tag_IsJoinGame) == 0)
            {
                NetRespond_IsJoinGame.doAskCilentReq_IsJoinGame(receiveObj.m_connId, text);
            }
            // 请求恢复房间
            else if (tag.CompareTo(TLJCommon.Consts.Tag_RetryJoinGame) == 0)
            {
                NetRespond_RetryJoinGame.doAskCilentReq_RetryJoinGame(receiveObj.m_connId, text);
            }
            // 自定义牌型
            else if (tag.CompareTo(TLJCommon.Consts.Tag_DebugSetPoker) == 0)
            {
                NetRespond_DebugSetPoker.doAskCilentReq_DebugSetPoker(receiveObj.m_connId, text);
            }
            // 心跳
            else if (tag.CompareTo(TLJCommon.Consts.Tag_HeartBeat_Play) == 0)
            {
                NetRespond_HeartBeat_Play.doAskCilentReq_HeartBeat_Play(receiveObj.m_connId, text);
            }
            // 解散房间
            else if (tag.CompareTo(TLJCommon.Consts.Tag_BreakRoom) == 0)
            {
                NetRespond_BreakRoom.doAskCilentReq_BreakRoom(receiveObj.m_connId, text);
            }
            // 斗地主相关
            else if (tag.CompareTo(TLJCommon.Consts.Tag_DouDiZhu_Game) == 0)
            {
                PlayLogic_DDZ.getInstance().OnReceive(receiveObj.m_connId, text);
            }
            // 未知Tag
            else
            {
                LogUtil.getInstance().addDebugLog("未知Tag:" + tag);
            }
        }
        else
        {
            // 传过来的数据没有tag字段的,一律不理
            // 日志
            {
                PlayerData playerData = GameUtil.getPlayerDataByConnId(receiveObj.m_connId);
                if (playerData != null)
                {
                    RoomData room = GameUtil.getRoomByUid(playerData.m_uid);
                    if (room != null)
                    {
                        LogUtil.getInstance().writeRoomLog(room, "客户端传来的数据没有Tag:" + text);
                    }
                    else
                    {
                        LogUtil.getInstance().addDebugLog("客户端传来的数据没有Tag:" + text);
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog("客户端传来的数据没有Tag:" + text);
                }
            }
            return;
        }
    }