Exemplo n.º 1
0
        internal void StartBattleRoom()
        {
            this.CurrentState = RoomState.Game;  //房间进入游戏状态
            RoomServerInfo svrInfo;

            if (m_LobbyInfo.RoomServerInfos.TryGetValue(m_RoomServerName, out svrInfo))
            {
                foreach (WeakReference userRef in m_Users.Values)
                {
                    UserInfo info = userRef.Target as UserInfo;
                    if (info != null)
                    {
                        JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                        startGameResultMsg.m_Guid = info.Guid;
                        ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                        protoData.server_ip   = svrInfo.ServerIp;
                        protoData.server_port = svrInfo.ServerPort;
                        protoData.key         = info.Key;
                        protoData.hero_id     = info.HeroId;
                        protoData.camp_id     = info.CampId;
                        protoData.scene_type  = SceneType;
                        protoData.result      = (int)GeneralOperationResult.LC_Succeed;

                        startGameResultMsg.m_ProtoData = protoData;

                        JsonMessageDispatcher.SendDcoreMessage(info.NodeName, startGameResultMsg);
                        LogSys.Log(LOG_TYPE.DEBUG, "StartGameResult, guid:{0},key:{1},ip:{2},port:{3},hero:{4},camp:{5},scene:{6}", info.Guid, info.Key, svrInfo.ServerIp, svrInfo.ServerPort, info.HeroId, protoData.camp_id, SceneType);
                    }
                }
            }
        }
Exemplo n.º 2
0
        //响应RoomServer玩家重新连接进入房间的反馈消息
        internal void OnReplyReconnectUser(ulong userGuid, int roomID, bool isSuccess)
        {
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(userGuid);

            if (user == null)
            {
                return;
            }
            if (isSuccess)
            {
                user.CurrentState = UserState.Room;
                RoomInfo room = m_LobbyInfo.GetRoomByID(roomID);
                if (null != room)
                {
                    RoomServerInfo svrInfo;
                    if (m_LobbyInfo.RoomServerInfos.TryGetValue(room.RoomServerName, out svrInfo))
                    {
                        if (null != svrInfo)
                        {
                            JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                            startGameResultMsg.m_Guid = user.Guid;
                            ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                            protoData.server_ip   = svrInfo.ServerIp;
                            protoData.server_port = svrInfo.ServerPort;
                            protoData.key         = user.Key;
                            protoData.hero_id     = user.HeroId;
                            protoData.camp_id     = user.CampId;
                            protoData.scene_type  = room.SceneType;
                            protoData.match_key   = user.CurrentBattleInfo.MatchKey;
                            protoData.result      = (int)GeneralOperationResult.LC_Succeed;

                            startGameResultMsg.m_ProtoData = protoData;
                            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, startGameResultMsg);
                            //重新进入房间成功
                            LogSys.Log(LOG_TYPE.INFO, "User Reconnected RoomServer Success ! , guid:{0}", userGuid);
                        }
                    }
                }
            }
            else
            {
                user.CurrentState = UserState.Online;

                LogSys.Log(LOG_TYPE.INFO, "User Reconnected RoomServer Failed ! , guid:{0}", userGuid);
            }
        }
Exemplo n.º 3
0
        internal void RequestSinglePVE(ulong guid, int sceneId)
        {
            Data_SceneConfig cfg = SceneConfigProvider.Instance.GetSceneConfigById(sceneId);

            if (null == cfg || cfg.m_Type == (int)SceneTypeEnum.TYPE_PVE)
            {
                //单人pve不建立房间,直接开始游戏(todo:奖励记到人身上[多人的奖励也是这样])
                DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
                UserInfo             user        = dataProcess.GetUserInfo(guid);
                if (user != null)
                {
                    user.CurrentBattleInfo.init(sceneId, user.HeroId);
                    SyncCombatData(user);
                    JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                    startGameResultMsg.m_Guid = user.Guid;
                    ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                    GeneralOperationResult result = GeneralOperationResult.LC_Succeed;
                    if (user.CurStamina >= cfg.m_CostStamina)
                    {
                        if (!GlobalVariables.Instance.IsDebug)
                        {
                            int preSceneId = SceneConfigProvider.Instance.GetPreSceneId(sceneId);
                            if (-1 != preSceneId)
                            {
                                if (!user.SceneData.ContainsKey(preSceneId))
                                {
                                    LogSystem.Error("player {0} try to enter an Illegal scene {1}", user.Guid, sceneId);
                                    return;
                                }
                            }
                            if (cfg.m_SubType == (int)SceneSubTypeEnum.TYPE_ELITE && user.GetCompletedSceneCount(sceneId) >= user.MaxEliteSceneCompletedCount)
                            {
                                LogSystem.Error("player {0} enter an Elite scene {1} too many times {2}", user.Guid, sceneId, user.GetCompletedSceneCount(sceneId));
                                return;
                            }
                        }
                        protoData.server_ip   = "127.0.0.1";
                        protoData.server_port = 9001;
                        protoData.key         = user.Key;
                        protoData.hero_id     = user.HeroId;
                        protoData.camp_id     = (int)CampIdEnum.Blue;
                        protoData.scene_type  = sceneId;
                        protoData.match_key   = user.CurrentBattleInfo.MatchKey;
                        result            = GeneralOperationResult.LC_Succeed;
                        user.CurrentState = UserState.Pve;
                    }
                    else
                    {
                        result = GeneralOperationResult.LC_Failure_CostError;
                    }
                    protoData.result = (int)result;
                    startGameResultMsg.m_ProtoData = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, startGameResultMsg);
                    LogSys.Log(LOG_TYPE.INFO, "Single Player Room will run on Lobby without room and roomserver, user {0} scene {1}", guid, sceneId);
                    /// norm log
                    AccountInfo accountInfo = dataProcess.FindAccountInfoById(user.AccountId);
                    if (null != accountInfo)
                    {
                        /// pvefight
                        LogSys.NormLog("PVEfight", LobbyConfig.AppKeyStr, accountInfo.ClientGameVersion, Module.pvefight, LobbyConfig.LogNormVersionStr,
                                       "B4110", accountInfo.LogicServerId, accountInfo.AccountId, user.Guid, user.Level, sceneId, (int)FightingType.General, "null",
                                       (int)PvefightResult.Failure, "null", "null");
                    }
                }
            }
        }