void connectinInThread()
    {
        while (!m_tcpClient.Connect(NetConfig.s_mySqlService_ip, (ushort)NetConfig.s_mySqlService_port, false))
        {
            // 连接数据库服务器失败的话会一直尝试连接
            LogUtil.getInstance().addDebugLog("连接数据库服务器失败");
            Thread.Sleep(1000);
        }

        m_isConnecting = true;
        LogUtil.getInstance().addDebugLog("连接数据库服务器成功");

        // 游戏在线统计
        Request_OnlineStatistics.doRequest("", 0, "", true, (int)Request_OnlineStatistics.OnlineStatisticsType.OnlineStatisticsType_clear);

        // 数据清空
        {
            PVPGameRoomDataScript.clear();
        }

        {
            // 拉取机器人列表
            Request_GetAIList.doRequest();
        }

        return;
    }
Ejemplo n.º 2
0
    public static PVPGameRoomDataScript getInstance()
    {
        if (s_instance == null)
        {
            s_instance = new PVPGameRoomDataScript();
        }

        return(s_instance);
    }
    public static void onMySqlRespond(int connId, string respondData)
    {
        try
        {
            // 初始化房间数据
            PVPGameRoomDataScript.getInstance().initJson(respondData);

            // 发送给客户端
            {
                //PlayService.m_serverUtil.sendMessage((IntPtr)connId, respondData);

                JObject jo        = JObject.Parse(respondData);
                JArray  room_list = (JArray)JsonConvert.DeserializeObject(jo.GetValue("room_list").ToString());

                {
                    JObject respondJO = new JObject();
                    respondJO.Add("tag", jo.GetValue("tag"));
                    respondJO.Add("code", jo.GetValue("code"));

                    {
                        JArray ja = new JArray();
                        respondJO.Add("room_list", ja);

                        for (int i = 0; i < room_list.Count; i++)
                        {
                            JObject temp = new JObject();

                            temp.Add("id", room_list[i]["id"]);
                            temp.Add("gameroomtype", room_list[i]["gameroomtype"]);
                            temp.Add("gameroomname", room_list[i]["gameroomname"]);
                            temp.Add("kaisairenshu", room_list[i]["kaisairenshu"]);
                            temp.Add("baomingfei", room_list[i]["baomingfei"]);
                            temp.Add("reward", room_list[i]["reward"]);

                            temp.Add("baomingrenshu", GameUtil.getGameRoomPlayerCount(room_list[i]["gameroomtype"].ToString()));

                            ja.Add(temp);
                        }
                    }

                    PlayService.m_serverUtil.sendMessage((IntPtr)connId, respondJO.ToString());
                }
            }
        }
        catch (Exception ex)
        {
            LogUtil.getInstance().addDebugLog(ex.Message);

            // 客户端参数错误
            //respondJO.Add("code", Convert.ToInt32(TLJCommon.Consts.Code.Code_ParamError));

            // 发送给客户端
            //LogicService.m_serverUtil.sendMessage(connId, respondJO.ToString());
        }
    }
Ejemplo n.º 4
0
    public void showHuaFeiChang()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("PVPChoiceScript_hotfix", "showHuaFeiChang"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.PVPChoiceScript_hotfix", "showHuaFeiChang", null, null);
            return;
        }

        m_curShowTiaoZhanSai = false;

        m_ListViewScript.clear();

        {
            m_tab_bg.transform.localPosition = new Vector3(83, 0, 0);

            CommonUtil.setImageSpriteByAssetBundle(m_button_tiaozhansai.transform.Find("Image").GetComponent <Image>(), "game.unity3d", "tiaozhansai_weixuanze");
            CommonUtil.setImageSpriteByAssetBundle(m_button_huafeisai.transform.Find("Image").GetComponent <Image>(), "game.unity3d", "huafeisai_xuanze");
        }

        for (int i = 0; i < PVPGameRoomDataScript.getInstance().getDataList().Count; i++)
        {
            List <string> list = new List <string>();
            CommonUtil.splitStr(PVPGameRoomDataScript.getInstance().getDataList()[i].gameroomtype, list, '_');

            if (list[1].CompareTo("HuaFei") == 0)
            {
                GameObject prefab = Resources.Load("Prefabs/UI/Item/PVP_List_Item") as GameObject;
                GameObject obj    = MonoBehaviour.Instantiate(prefab);

                obj.GetComponent <PVP_List_Item_Script>().setPVPGameRoomData(PVPGameRoomDataScript.getInstance().getDataList()[i]);
                m_ListViewScript.addItem(obj);
            }
        }

        m_ListViewScript.addItemEnd();
    }
Ejemplo n.º 5
0
    // 游戏结束
    public override void gameOver(RoomData now_room)
    {
        try
        {
            now_room.setRoomState(RoomState.RoomState_end);

            LogUtil.getInstance().writeRoomLog(now_room, m_logFlag + "----" + ":比赛结束,roomid = :" + now_room.getRoomId());

            // 游戏在线统计
            for (int i = 0; i < now_room.getPlayerDataList().Count; i++)
            {
                Request_OnlineStatistics.doRequest(now_room.getPlayerDataList()[i].m_uid, now_room.getRoomId(), now_room.m_gameRoomType, now_room.getPlayerDataList()[i].m_isAI, (int)Request_OnlineStatistics.OnlineStatisticsType.OnlineStatisticsType_exit);
            }

            // 计算每个玩家的金币(积分)
            GameUtil.setPlayerScore(now_room, true);

            List <PlayerData> winPlayerList = new List <PlayerData>();

            string gameRoomType = now_room.m_gameRoomType;
            int    rounds_pvp   = now_room.m_rounds_pvp;


            bool isContiune   = true;       // 是否打到最后一轮
            bool isJueShengJu = false;      // 下一局是否是决胜局

            {
                PVPGameRoomData pvpGameRoomData = PVPGameRoomDataScript.getInstance().getDataByRoomType(gameRoomType);
                if (pvpGameRoomData == null)
                {
                    LogUtil.getInstance().writeRoomLog(now_room, "获取比赛场信息失败:" + gameRoomType);
                    return;
                }

                int kaisairenshu = pvpGameRoomData.kaisairenshu;
                switch (kaisairenshu)
                {
                case 8:
                {
                    if (rounds_pvp == 3)
                    {
                        isContiune = false;
                    }
                    // 决胜局
                    else if (rounds_pvp == 2)
                    {
                        isJueShengJu = true;
                    }
                }
                break;

                case 16:
                {
                    if (rounds_pvp == 4)
                    {
                        isContiune = false;
                    }
                    // 决胜局
                    else if (rounds_pvp == 3)
                    {
                        isJueShengJu = true;
                    }
                }
                break;

                case 32:
                {
                    if (rounds_pvp == 5)
                    {
                        isContiune = false;
                    }
                    // 决胜局
                    else if (rounds_pvp == 4)
                    {
                        isJueShengJu = true;
                    }
                }
                break;
                }
            }

            List <string> winnerList = new List <string>();

            // 逻辑处理
            {
                // 闲家赢
                if (now_room.m_getAllScore >= 80)
                {
                    for (int i = 0; i < now_room.getPlayerDataList().Count; i++)
                    {
                        if (now_room.getPlayerDataList()[i].m_isBanker == 0)
                        {
                            winnerList.Add(now_room.getPlayerDataList()[i].m_uid);

                            ++now_room.getPlayerDataList()[i].m_myLevelPoker;
                            if (now_room.getPlayerDataList()[i].m_myLevelPoker == 15)
                            {
                                now_room.getPlayerDataList()[i].m_myLevelPoker = 2;
                            }

                            now_room.m_levelPokerNum = now_room.getPlayerDataList()[i].m_myLevelPoker;

                            winPlayerList.Add(now_room.getPlayerDataList()[i]);

                            // 提交任务
                            if (!now_room.getPlayerDataList()[i].m_isAI)
                            {
                                Request_ProgressTask.doRequest(now_room.getPlayerDataList()[i].m_uid, 203);
                                Request_ProgressTask.doRequest(now_room.getPlayerDataList()[i].m_uid, 212);
                            }

                            // 记录胜利次数数据
                            {
                                Request_RecordUserGameData.doRequest(now_room.getPlayerDataList()[i].m_uid, now_room.m_gameRoomType, (int)TLJCommon.Consts.GameAction.GameAction_Win);
                            }

                            // 分数在原来的基础上减半,防止玩家之间分数差距太大
                            {
                                now_room.getPlayerDataList()[i].m_score /= 2;
                            }
                        }
                        // 加入淘汰人员列表里
                        else
                        {
                            //PVPChangCiUtil.getInstance().addPlayerToThere(now_room.m_gameRoomType, now_room.getPlayerDataList()[i]);

                            //// 分数在原来的基础上减10000,防止比晋级的人分数高,影响排名
                            //if (!isJueShengJu && isContiune)
                            //{
                            //    now_room.getPlayerDataList()[i].m_score -= 10000;
                            //}
                        }
                    }
                }
                // 庄家赢
                else
                {
                    for (int i = 0; i < now_room.getPlayerDataList().Count; i++)
                    {
                        if (now_room.getPlayerDataList()[i].m_isBanker == 1)
                        {
                            winnerList.Add(now_room.getPlayerDataList()[i].m_uid);

                            ++now_room.getPlayerDataList()[i].m_myLevelPoker;
                            if (now_room.getPlayerDataList()[i].m_myLevelPoker == 15)
                            {
                                now_room.getPlayerDataList()[i].m_myLevelPoker = 2;
                            }

                            now_room.m_levelPokerNum = now_room.getPlayerDataList()[i].m_myLevelPoker;

                            winPlayerList.Add(now_room.getPlayerDataList()[i]);

                            // 提交任务
                            if (!now_room.getPlayerDataList()[i].m_isAI)
                            {
                                Request_ProgressTask.doRequest(now_room.getPlayerDataList()[i].m_uid, 212);
                            }

                            // 记录胜利次数数据
                            {
                                Request_RecordUserGameData.doRequest(now_room.getPlayerDataList()[i].m_uid, now_room.m_gameRoomType, (int)TLJCommon.Consts.GameAction.GameAction_Win);
                            }

                            // 分数在原来的基础上减半,防止玩家之间分数差距太大
                            {
                                now_room.getPlayerDataList()[i].m_score /= 2;
                            }
                        }
                        // 加入淘汰人员列表里
                        else
                        {
                            //PVPChangCiUtil.getInstance().addPlayerToThere(now_room.m_gameRoomType, now_room.getPlayerDataList()[i]);

                            //// 分数在原来的基础上减10000,防止比晋级的人分数高,影响排名
                            //if (!isJueShengJu && isContiune)
                            //{
                            //    now_room.getPlayerDataList()[i].m_score -= 10000;
                            //}
                        }
                    }
                }
            }

            for (int i = 0; i < winPlayerList.Count; i++)
            {
                LogUtil.getInstance().writeRoomLog(now_room, m_logFlag + "----" + ":胜利的人:" + winPlayerList[i].m_uid + "  isBanker:" + winPlayerList[i].m_isBanker);
            }

            // 通知
            {
                JObject respondJO;
                {
                    respondJO = new JObject();

                    respondJO.Add("tag", m_tag);
                    respondJO.Add("playAction", (int)TLJCommon.Consts.PlayAction.PlayAction_GameOver);
                    respondJO.Add("getAllScore", now_room.m_getAllScore);
                    respondJO.Add("isBankerWin", now_room.m_getAllScore >= 80 ? 0 : 1);
                    respondJO.Add("isContiune", isContiune);
                }

                // 给在线的人推送
                for (int i = 0; i < now_room.getPlayerDataList().Count; i++)
                {
                    // 推送给客户端
                    if (!now_room.getPlayerDataList()[i].isOffLine())
                    {
                        if (!(now_room.getPlayerDataList()[i].m_isAI))
                        {
                            if (respondJO.GetValue("score") != null)
                            {
                                respondJO.Remove("score");
                            }

                            respondJO.Add("score", now_room.getPlayerDataList()[i].m_score);

                            PlayService.m_serverUtil.sendMessage(now_room.getPlayerDataList()[i].m_connId, respondJO.ToString());
                        }
                    }
                    else
                    {
                        if (!(now_room.getPlayerDataList()[i].m_isAI))
                        {
                            // 记录逃跑数据
                            Request_RecordUserGameData.doRequest(now_room.getPlayerDataList()[i].m_uid, now_room.m_gameRoomType, (int)TLJCommon.Consts.GameAction.GameAction_Run);
                        }
                    }

                    // 告诉数据库服务器该玩家打完一局
                    {
                        Request_GameOver.doRequest(now_room.getPlayerDataList()[i].m_uid, now_room.m_gameRoomType);
                    }
                }
            }

            if (isJueShengJu)
            {
                // 游戏数据统计
                Request_GameStatistics.doRequest(now_room, winnerList);

                jueshengju(now_room);

                return;
            }

            // 进入新房间,准备开始下一局
            if (isContiune)
            {
                // 游戏数据统计
                Request_GameStatistics.doRequest(now_room, winnerList);

                // 删除该房间
                {
                    LogUtil.getInstance().writeRoomLog(now_room, m_logFlag + ":本局打完,强制解散该房间:" + now_room.getRoomId());

                    GameLogic.removeRoom(this, now_room, true);
                }

                for (int i = 0; i < winPlayerList.Count; i++)
                {
                    if (!winPlayerList[i].isOffLine())
                    {
                        {
                            RoomData room = null;

                            // 玩家数据清理
                            {
                                winPlayerList[i].m_isBanker = 0;
                            }

                            lock (m_roomList)
                            {
                                // 在已有的房间寻找可以加入的房间
                                for (int j = 0; j < m_roomList.Count; j++)
                                {
                                    if ((gameRoomType.CompareTo(m_roomList[j].m_gameRoomType) == 0) && ((rounds_pvp + 1) == m_roomList[j].m_rounds_pvp) && (m_roomList[j].getRoomState() == RoomState.RoomState_waiting))
                                    {
                                        if (m_roomList[j].joinPlayer(winPlayerList[i]))
                                        {
                                            winPlayerList[i].clearData();
                                            room = m_roomList[j];
                                            LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":找到新房间:" + room.getRoomId());

                                            break;
                                        }
                                    }
                                }

                                // 当前没有房间可加入的话则创建一个新的房间
                                if (room == null)
                                {
                                    winPlayerList[i].clearData();

                                    //room = new RoomData(this, m_roomList.Count + 1, gameRoomType);
                                    room = new RoomData(this, gameRoomType);
                                    room.joinPlayer(winPlayerList[i]);
                                    room.m_rounds_pvp = rounds_pvp + 1;

                                    m_roomList.Add(room);

                                    LogUtil.getInstance().writeRoomLog(room, "新建比赛场房间:" + room.getRoomId());
                                }
                            }

                            LogUtil.getInstance().writeRoomLog(room, ":该新房间人数:" + room.getPlayerDataList().Count);
                            if (room.getPlayerDataList().Count == 4)
                            {
                                // 延迟3秒开赛
                                room.m_timerUtil.startTimer(3000, TimerType.TimerType_pvpNextStartGame);
                            }
                        }
                    }
                }
            }
            // 所有局数已经打完
            else
            {
                {
                    //for (int i = 0; i < winPlayerList.Count; i++)
                    //{
                    //    // 加入淘汰人员列表里
                    //    PVPChangCiUtil.getInstance().addPlayerToThere(gameRoomType, winPlayerList[i]);
                    //}

                    // 加入到8、16人列表里
                    {
                        for (int i = 0; i < now_room.getPlayerDataList().Count; i++)
                        {
                            PVPChangCiUtil.getInstance().addPlayerToThere(now_room);
                        }
                    }
                }

                PVPRoomPlayerList curPVPRoomPlayerList = PVPChangCiUtil.getInstance().getPVPRoomPlayerListByUid(winPlayerList[0].m_uid);
                if (curPVPRoomPlayerList != null)
                {
                    PVPChangCiUtil.getInstance().sortPVPRoomPlayerList(curPVPRoomPlayerList);
                    PVPChangCiUtil.getInstance().deletePVPRoomPlayerList(curPVPRoomPlayerList);

                    GameUtil.setPVPReward(curPVPRoomPlayerList);

                    // 游戏数据统计
                    Request_GameStatistics.doRequest(now_room, winnerList);

                    string gameroomname = PVPGameRoomDataScript.getInstance().getDataByRoomType(curPVPRoomPlayerList.m_gameRoomType).gameroomname;

                    // 用邮件给他们发奖励
                    for (int i = 0; i < curPVPRoomPlayerList.m_playerList.Count; i++)
                    {
                        LogUtil.getInstance().addDebugLog(m_tag + "----名次" + (i + 1) + "  id = " + curPVPRoomPlayerList.m_playerList[i].m_uid + " 分数为" + curPVPRoomPlayerList.m_playerList[i].m_score + "  奖励为:" + curPVPRoomPlayerList.m_playerList[i].m_pvpReward);

                        if (curPVPRoomPlayerList.m_playerList[i].m_pvpReward.CompareTo("") != 0)
                        {
                            string title   = gameroomname + "奖励";
                            string content = "恭喜您在" + gameroomname + "获得第" + curPVPRoomPlayerList.m_playerList[i].m_rank + "名,为您送上专属奖励";
                            Request_SendMailToUser.doRequest(curPVPRoomPlayerList.m_playerList[i].m_uid, title, content, curPVPRoomPlayerList.m_playerList[i].m_pvpReward);
                        }

                        // 提交任务
                        if (i == 0)
                        {
                            Request_ProgressTask.doRequest(curPVPRoomPlayerList.m_playerList[i].m_uid, 214);
                        }
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_tag + "----curPVPRoomPlayerList == null");
                }

                {
                    JObject respondJO;
                    {
                        respondJO = new JObject();

                        respondJO.Add("tag", m_tag);
                        respondJO.Add("playAction", (int)TLJCommon.Consts.PlayAction.PlayAction_PVPGameOver);
                    }

                    // 给在线的人推送
                    for (int i = 0; i < now_room.getPlayerDataList().Count; i++)
                    {
                        if (!now_room.getPlayerDataList()[i].isOffLine())
                        {
                            if (respondJO.GetValue("mingci") != null)
                            {
                                respondJO.Remove("mingci");
                            }

                            if (respondJO.GetValue("pvpreward") != null)
                            {
                                respondJO.Remove("pvpreward");
                            }

                            respondJO.Add("mingci", now_room.getPlayerDataList()[i].m_rank);
                            respondJO.Add("pvpreward", now_room.getPlayerDataList()[i].m_pvpReward);

                            PlayService.m_serverUtil.sendMessage(now_room.getPlayerDataList()[i].m_connId, respondJO.ToString());
                        }
                    }
                }

                // 删除该房间
                {
                    LogUtil.getInstance().writeRoomLog(now_room, m_logFlag + "----" + ":PVP所有局数已打完,强制解散该房间:" + now_room.getRoomId());

                    GameLogic.removeRoom(this, now_room, true);
                }
            }
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":gameOver异常:" + ex);
        }
    }
Ejemplo n.º 6
0
    public override bool doTaskPlayerCloseConn(string uid)
    {
        try
        {
            RoomData room = getRoomByUid(uid);
            if (room == null)
            {
                return(false);
            }

            PlayerData playerData = GameUtil.getPlayerDataByUid(uid);
            if (playerData == null)
            {
                return(false);
            }

            //// 记录逃跑数据
            //if ((m_roomList[i].m_roomState != RoomState.RoomState_waiting) &&
            //    (m_roomList[i].m_roomState != RoomState.RoomState_end))
            //{
            //    Request_RecordUserGameData.doRequest(room.getPlayerDataList()[i].m_uid, room.m_gameRoomType, (int)TLJCommon.Consts.GameAction.GameAction_Run);
            //}

            switch (room.getRoomState())
            {
            case RoomState.RoomState_waiting:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在本桌满人之前退出:" + playerData.m_uid);

                    // 还回报名费
                    {
                        PVPGameRoomData pvpGameRoomData = PVPGameRoomDataScript.getInstance().getDataByRoomType(room.m_gameRoomType);
                        string          baomingfei      = pvpGameRoomData.baomingfei;

                        if (baomingfei.CompareTo("0") != 0)
                        {
                            List <string> tempList = new List <string>();
                            CommonUtil.splitStr(baomingfei, tempList, ':');

                            int id  = int.Parse(tempList[0]);
                            int num = int.Parse(tempList[1]);

                            string content = pvpGameRoomData.gameroomname + "报名费返还:";
                            if (id == 1)
                            {
                                content += ("金币x" + num);
                            }
                            else
                            {
                                content += ("蓝钻石x" + num);
                            }

                            Request_SendMailToUser.doRequest(playerData.m_uid, "报名费返还", content, baomingfei);
                        }
                    }

                    room.getPlayerDataList().Remove(playerData);

                    if (GameUtil.checkRoomNonePlayer(room))
                    {
                        LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此房间人数为0,解散房间:" + room.getRoomId());

                        GameLogic.removeRoom(this, room, true);
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            case RoomState.RoomState_qiangzhu:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在抢主阶段退出:" + playerData.m_uid);

                    playerData.setIsOffLine(true);
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            case RoomState.RoomState_zhuangjiamaidi:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在庄家埋底阶段退出:" + playerData.m_uid);

                    playerData.setIsOffLine(true);

                    //TrusteeshipLogic.trusteeshipLogic_MaiDi(this, room, playerDataList[j]);
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            //case RoomData.RoomState.RoomState_fanzhu:
            //    {
            //        LogUtil.getInstance().addDebugLog("玩家在反主阶段退出:" + playerDataList[j].m_uid);

            //        playerDataList[j].m_isOffLine = true;
            //    }
            //    break;

            case RoomState.RoomState_chaodi:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在抄底阶段退出:" + playerData.m_uid);

                    playerData.setIsOffLine(true);

                    //TrusteeshipLogic.trusteeshipLogic_ChaoDi(this, room, playerDataList[j]);
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            case RoomState.RoomState_othermaidi:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在Other埋底阶段退出:" + playerData.m_uid);

                    playerData.setIsOffLine(true);

                    //TrusteeshipLogic.trusteeshipLogic_MaiDi(this, room, playerDataList[j]);
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            case RoomState.RoomState_gaming:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在游戏中退出:" + playerData.m_uid);
                    playerData.setIsOffLine(true);

                    // 如果当前房间正好轮到此人出牌
                    if (room.m_curOutPokerPlayer.m_uid.CompareTo(playerData.m_uid) == 0)
                    {
                        //TrusteeshipLogic.trusteeshipLogic_OutPoker(this, m_roomList[i], playerDataList[j]);
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            case RoomState.RoomState_end:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在本桌打完后退出:" + playerData.m_uid);

                    room.getPlayerDataList().Remove(playerData);
                    if (room.getPlayerDataList().Count == 0)
                    {
                        LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此房间人数为0,解散房间:" + room.getRoomId());

                        GameLogic.removeRoom(this, room, true);
                    }
                    else
                    {
                        // 检查此房间内是否有人想继续游戏,有的话则告诉他失败
                        {
                            for (int k = room.getPlayerDataList().Count - 1; k >= 0; k--)
                            {
                                if (room.getPlayerDataList()[k].m_isContinueGame)
                                {
                                    {
                                        JObject respondJO = new JObject();
                                        respondJO.Add("tag", m_tag);
                                        respondJO.Add("playAction", (int)TLJCommon.Consts.PlayAction.PlayAction_ContinueGameFail);
                                        respondJO.Add("uid", room.getPlayerDataList()[k].m_uid);

                                        // 发送给客户端
                                        PlayService.m_serverUtil.sendMessage(room.getPlayerDataList()[k].m_connId, respondJO.ToString());
                                    }

                                    room.getPlayerDataList().RemoveAt(k);
                                }
                            }
                        }

                        // 如果房间人数为空,则删除此房间
                        {
                            if (GameUtil.checkRoomNonePlayer(room))
                            {
                                LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此房间人数为0,解散房间:" + room.getRoomId());

                                GameLogic.removeRoom(this, room, true);
                            }
                        }
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            default:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在未知阶段退出:" + playerData.m_uid);

                    room.getPlayerDataList().Remove(playerData);

                    if (GameUtil.checkRoomNonePlayer(room))
                    {
                        LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此房间人数为0,解散房间:" + room.getRoomId());

                        GameLogic.removeRoom(this, room, true);
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;
            }

            return(true);
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":doTaskPlayerCloseConn异常:" + ex);
        }

        return(false);
    }
Ejemplo n.º 7
0
    void doTask_JoinGame(IntPtr connId, string data)
    {
        try
        {
            JObject jo           = JObject.Parse(data);
            string  tag          = jo.GetValue("tag").ToString();
            string  uid          = jo.GetValue("uid").ToString();
            string  gameroomtype = jo.GetValue("gameroomtype").ToString();
            int     playAction   = Convert.ToInt32(jo.GetValue("playAction"));

            RoomData room = null;

            // 检测该玩家是否已经加入房间
            if (GameUtil.checkPlayerIsInRoom(uid))
            {
                // 给客户端回复
                {
                    JObject respondJO = new JObject();
                    respondJO.Add("tag", tag);
                    respondJO.Add("playAction", playAction);
                    respondJO.Add("gameRoomType", GameUtil.getRoomByUid(uid).m_gameRoomType);
                    respondJO.Add("code", (int)TLJCommon.Consts.Code.Code_CommonFail);

                    // 发送给客户端
                    PlayService.m_serverUtil.sendMessage(connId, respondJO.ToString());
                }

                return;
            }

            lock (m_roomList)
            {
                // 在已有的房间寻找可以加入的房间
                for (int i = 0; i < m_roomList.Count; i++)
                {
                    //if (gameroomtype.CompareTo(m_roomList[i].m_gameRoomType) == 0)
                    if ((gameroomtype.CompareTo(m_roomList[i].m_gameRoomType) == 0) && (1 == m_roomList[i].m_rounds_pvp) && (m_roomList[i].getRoomState() == RoomState.RoomState_waiting))
                    {
                        if (m_roomList[i].joinPlayer(new PlayerData(connId, uid, false, gameroomtype)))
                        {
                            room = m_roomList[i];
                            break;
                        }
                    }
                }

                // 当前没有房间可加入的话则创建一个新的房间
                if (room == null)
                {
                    //room = new RoomData(this, m_roomList.Count + 1, gameroomtype);
                    room = new RoomData(this, gameroomtype);
                    room.joinPlayer(new PlayerData(connId, uid, false, gameroomtype));

                    m_roomList.Add(room);

                    LogUtil.getInstance().writeRoomLog(room, "新建比赛场房间:" + room.getRoomId());
                }
            }

            // 扣除报名费
            {
                string baomingfei = PVPGameRoomDataScript.getInstance().getDataByRoomType(gameroomtype).baomingfei;
                if (baomingfei.CompareTo("0") != 0)
                {
                    List <string> tempList = new List <string>();
                    CommonUtil.splitStr(baomingfei, tempList, ':');
                    Request_ChangeUserWealth.doRequest(uid, int.Parse(tempList[0]), -int.Parse(tempList[1]), "比赛场报名费");
                }
            }

            // 加入房间成功,给客户端回复
            {
                JObject respondJO = new JObject();
                respondJO.Add("tag", tag);
                respondJO.Add("playAction", playAction);
                respondJO.Add("gameRoomType", gameroomtype);
                respondJO.Add("code", (int)TLJCommon.Consts.Code.Code_OK);
                respondJO.Add("roomId", room.getRoomId());

                // 发送给客户端
                PlayService.m_serverUtil.sendMessage(connId, respondJO.ToString());
            }

            // 检测房间人数是否可以开赛
            GameLogic.checkRoomStartGame(room, m_tag, true);
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":doTask_JoinGame异常:" + ex);
        }
    }
Ejemplo n.º 8
0
    public static string getRoomName(string gameRoomType)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("GameUtil_hotfix", "getRoomName"))
        {
            string s = (string)ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.GameUtil_hotfix", "getRoomName", null, gameRoomType);
            return(s);
        }

        string roonName = "";

        if (gameRoomType.CompareTo("XiuXian_JingDian_Common") == 0)
        {
            roonName = "经典玩法";
        }
        else if (gameRoomType.CompareTo("XiuXian_JingDian_ChuJi") == 0)
        {
            roonName = "经典玩法-新手场";
        }
        else if (gameRoomType.CompareTo("XiuXian_JingDian_ZhongJi") == 0)
        {
            roonName = "经典玩法-精英场";
        }
        else if (gameRoomType.CompareTo("XiuXian_JingDian_GaoJi") == 0)
        {
            roonName = "经典玩法-大师场";
        }
        else if (gameRoomType.CompareTo("XiuXian_ChaoDi_Common") == 0)
        {
            roonName = "抄底玩法";
        }
        else if (gameRoomType.CompareTo("XiuXian_ChaoDi_ChuJi") == 0)
        {
            roonName = "抄底玩法-新手场";
        }
        else if (gameRoomType.CompareTo("XiuXian_ChaoDi_ZhongJi") == 0)
        {
            roonName = "抄底玩法-精英场";
        }
        else if (gameRoomType.CompareTo("XiuXian_ChaoDi_GaoJi") == 0)
        {
            roonName = "抄底玩法-大师场";
        }
        else
        {
            List <string> list = new List <string>();
            CommonUtil.splitStr(gameRoomType, list, '_');

            if (list.Count == 3)
            {
                if (list[0].CompareTo("PVP") == 0)
                {
                    PVPGameRoomData pvpGameRoomData = PVPGameRoomDataScript.getInstance().getDataByRoomType(gameRoomType);

                    if (pvpGameRoomData != null)
                    {
                        roonName = pvpGameRoomData.gameroomname;
                    }
                }
            }
        }

        return(roonName);
    }
Ejemplo n.º 9
0
    public static void setGameRoomTypeLogoPath(string gameroomtype, Image gameRoomLogo)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("GameUtil_hotfix", "setGameRoomTypeLogoPath"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.GameUtil_hotfix", "setGameRoomTypeLogoPath", null, gameroomtype, gameRoomLogo);
            return;
        }

        string path = "";

        if (gameroomtype.CompareTo(TLJCommon.Consts.GameRoomType_XiuXian_JingDian_Common) == 0)
        {
            path = "roomlogo_jingdian_common";
        }
        else if (gameroomtype.CompareTo(TLJCommon.Consts.GameRoomType_XiuXian_JingDian_ChuJi) == 0)
        {
            path = "roomlogo_jingdian_xinshou";
        }
        else if (gameroomtype.CompareTo(TLJCommon.Consts.GameRoomType_XiuXian_JingDian_ZhongJi) == 0)
        {
            path = "roomlogo_jingdian_jingying";
        }
        else if (gameroomtype.CompareTo(TLJCommon.Consts.GameRoomType_XiuXian_JingDian_GaoJi) == 0)
        {
            path = "roomlogo_jingdian_dashi";
        }
        else if (gameroomtype.CompareTo(TLJCommon.Consts.GameRoomType_XiuXian_ChaoDi_Common) == 0)
        {
            path = "roomlogo_chaodi_common";
        }
        else if (gameroomtype.CompareTo(TLJCommon.Consts.GameRoomType_XiuXian_ChaoDi_ChuJi) == 0)
        {
            path = "roomlogo_chaodi_xinshou";
        }
        else if (gameroomtype.CompareTo(TLJCommon.Consts.GameRoomType_XiuXian_ChaoDi_ZhongJi) == 0)
        {
            path = "roomlogo_chaodi_jingying";
        }
        else if (gameroomtype.CompareTo(TLJCommon.Consts.GameRoomType_XiuXian_ChaoDi_GaoJi) == 0)
        {
            path = "roomlogo_chaodi_dashi";
        }
        else
        {
            List <string> list = new List <string>();
            CommonUtil.splitStr(gameroomtype, list, '_');

            if (list.Count == 3)
            {
                if (list[0].CompareTo("PVP") == 0)
                {
                    // pvp金币场
                    if (list[1].CompareTo("JinBi") == 0)
                    {
                        path = "roomlogo_jinbichang";

                        PVPGameRoomData pvpGameRoomData = PVPGameRoomDataScript.getInstance().getDataByRoomType(gameroomtype);
                        if (pvpGameRoomData != null)
                        {
                            gameRoomLogo.transform.Find("Text").GetComponent <Text>().text = pvpGameRoomData.reward_num.ToString();
                        }

                        gameRoomLogo.transform.Find("Text").GetComponent <Text>().fontSize                = 23;
                        gameRoomLogo.transform.Find("Text").GetComponent <Text>().transform.localScale    = new Vector3(1, 1, 1);
                        gameRoomLogo.transform.Find("Text").GetComponent <Text>().transform.localPosition = new Vector3(-42.0f, -23.2f, 0);
                    }
                    // pvp话费场
                    else if (list[1].CompareTo("HuaFei") == 0)
                    {
                        path = "roomlogo_huafeichang";

                        PVPGameRoomData pvpGameRoomData = PVPGameRoomDataScript.getInstance().getDataByRoomType(gameroomtype);
                        if (pvpGameRoomData != null)
                        {
                            gameRoomLogo.transform.Find("Text").GetComponent <Text>().text = list[2];
                        }

                        gameRoomLogo.transform.Find("Text").GetComponent <Text>().fontSize                = 57;
                        gameRoomLogo.transform.Find("Text").GetComponent <Text>().transform.localScale    = new Vector3(1, 1, 1);
                        gameRoomLogo.transform.Find("Text").GetComponent <Text>().transform.localPosition = new Vector3(-34.4f, 53.2f, 0);
                    }
                }
            }
        }

        CommonUtil.setImageSpriteByAssetBundle(gameRoomLogo, "game.unity3d", path);
    }
Ejemplo n.º 10
0
    public static void setPVPReward(PVPRoomPlayerList curPVPRoomPlayerList)
    {
        string gameRoomType = curPVPRoomPlayerList.m_gameRoomType;

        List <string> list = new List <string>();

        CommonUtil.splitStr(gameRoomType, list, '_');

        if (list.Count == 3)
        {
            if (list[0].CompareTo("PVP") == 0)
            {
                PVPGameRoomData pvpGameRoomData = PVPGameRoomDataScript.getInstance().getDataByRoomType(gameRoomType);

                // PVP-金币场
                if (list[1].CompareTo("JinBi") == 0)
                {
                    // 2000金币场
                    if (pvpGameRoomData.reward_num == 2000)
                    {
                        // 第一名
                        {
                            int getHuiZhangNum = 1;

                            UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid);
                            if (userInfo_Game != null)
                            {
                                int vipLevel = userInfo_Game.vipLevel;

                                if ((vipLevel >= 2) && (vipLevel <= 4))
                                {
                                    getHuiZhangNum += 1;
                                }
                                else if ((vipLevel >= 5) && (vipLevel <= 7))
                                {
                                    getHuiZhangNum += 2;
                                }
                                else if ((vipLevel >= 8) && (vipLevel <= 10))
                                {
                                    getHuiZhangNum += 3;
                                }
                            }
                            else
                            {
                                TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空");
                            }

                            curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "1:2000;110:" + getHuiZhangNum;
                        }

                        // 第二名
                        {
                            curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:1000";
                        }
                    }
                    // 10000金币场
                    else if (pvpGameRoomData.reward_num == 10000)
                    {
                        // 第一名
                        {
                            int getHuiZhangNum = 1;

                            UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid);
                            if (userInfo_Game != null)
                            {
                                int vipLevel = userInfo_Game.vipLevel;

                                if ((vipLevel >= 2) && (vipLevel <= 4))
                                {
                                    getHuiZhangNum += 1;
                                }
                                else if ((vipLevel >= 5) && (vipLevel <= 7))
                                {
                                    getHuiZhangNum += 2;
                                }
                                else if ((vipLevel >= 8) && (vipLevel <= 10))
                                {
                                    getHuiZhangNum += 3;
                                }
                            }
                            else
                            {
                                TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空");
                            }

                            curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "1:10000;110:" + getHuiZhangNum;
                        }

                        // 第二名
                        {
                            curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:1000";
                        }
                    }
                    // 5000金币场(用于ios审核)
                    else if (pvpGameRoomData.reward_num == 5000)
                    {
                        // 第一名
                        {
                            int getHuiZhangNum = 1;

                            UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid);
                            if (userInfo_Game != null)
                            {
                                int vipLevel = userInfo_Game.vipLevel;

                                if ((vipLevel >= 2) && (vipLevel <= 4))
                                {
                                    getHuiZhangNum += 1;
                                }
                                else if ((vipLevel >= 5) && (vipLevel <= 7))
                                {
                                    getHuiZhangNum += 2;
                                }
                                else if ((vipLevel >= 8) && (vipLevel <= 10))
                                {
                                    getHuiZhangNum += 3;
                                }
                            }
                            else
                            {
                                TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空");
                            }

                            curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "1:5000;110:" + getHuiZhangNum;
                        }

                        // 第二名
                        {
                            curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:1000";
                        }
                    }
                }
                // PVP-话费场
                else if (list[1].CompareTo("HuaFei") == 0)
                {
                    // 1元话费场
                    if (list[2].CompareTo("1") == 0)
                    {
                        // 第一名
                        {
                            int getHuiZhangNum = 1;

                            UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid);
                            if (userInfo_Game != null)
                            {
                                int vipLevel = userInfo_Game.vipLevel;

                                if ((vipLevel >= 2) && (vipLevel <= 4))
                                {
                                    getHuiZhangNum += 1;
                                }
                                else if ((vipLevel >= 5) && (vipLevel <= 7))
                                {
                                    getHuiZhangNum += 2;
                                }
                                else if ((vipLevel >= 8) && (vipLevel <= 10))
                                {
                                    getHuiZhangNum += 3;
                                }
                            }
                            else
                            {
                                TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空");
                            }

                            curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "111:1;110:" + getHuiZhangNum;
                        }

                        // 第二名
                        {
                            curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:500";
                        }
                    }
                    // 5元话费场
                    else if (list[2].CompareTo("5") == 0)
                    {
                        // 第一名
                        {
                            int getHuiZhangNum = 2;

                            UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid);
                            if (userInfo_Game != null)
                            {
                                int vipLevel = userInfo_Game.vipLevel;

                                if ((vipLevel >= 2) && (vipLevel <= 4))
                                {
                                    getHuiZhangNum += 1;
                                }
                                else if ((vipLevel >= 5) && (vipLevel <= 7))
                                {
                                    getHuiZhangNum += 2;
                                }
                                else if ((vipLevel >= 8) && (vipLevel <= 10))
                                {
                                    getHuiZhangNum += 3;
                                }
                            }
                            else
                            {
                                TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空");
                            }

                            curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "112:1;110:" + getHuiZhangNum;
                        }

                        // 第二名
                        {
                            curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:5000;110:1";
                        }
                    }
                }
            }
        }
    }
 public static void clear()
 {
     s_instance = null;
 }