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);
        }
    }
Пример #2
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);
    }
Пример #3
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);
    }
Пример #4
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";
                        }
                    }
                }
            }
        }
    }