Наследование: global::ProtoBuf.IExtensible
        internal void RequestChangeSceneRoom(ulong guid, int sceneId, int wantRoomId)
        {
            UserInfo info = LobbyServer.Instance.UserProcessScheduler.GetUserInfo(guid);
            RoomInfo targetRoom = null;
            if (wantRoomId <= 0) {
                int roomId = m_LobbyInfo.FindSceneRoom(sceneId);
                if (roomId > 0) {
                    targetRoom = m_LobbyInfo.GetRoomByID(roomId);
                }
            } else {
                targetRoom = m_LobbyInfo.GetRoomByID(wantRoomId);
            }
            if (info != null && null != info.Room && null != targetRoom) {
                RoomInfo curRoom = info.Room;
                if (curRoom.RoomId != targetRoom.RoomId && targetRoom.UserCount < targetRoom.TotalCount) {
                    Msg_LR_ChangeScene msg = new Msg_LR_ChangeScene();
                    msg.UserGuid = guid;
                    msg.RoomID = curRoom.RoomId;
                    msg.TargetRoomID = targetRoom.RoomId;

                    LobbyServer.Instance.RoomSvrChannel.Send(curRoom.RoomServerName, msg);
                } else {
                    LobbyServer.Instance.HighlightPrompt(info, 42);//进入游戏失败,请稍后重试
                }
            } else {
                LobbyServer.Instance.HighlightPrompt(info, 42);//进入游戏失败,请稍后重试
            }
        }
Пример #2
0
 private void HandleChangeScene(Msg_LR_ChangeScene msg, PBChannel channel, int handle, uint seq)
 {
     ulong guid = msg.UserGuid;
     int roomid = msg.RoomID;
     int targetRoomId = msg.TargetRoomID;
     bool isFieldThread;
     int ix = GetActiveRoomThreadIndex(msg.RoomID, out isFieldThread);
     if (ix < 0) {
         Msg_RL_ChangeSceneResult replyBuilder = new Msg_RL_ChangeSceneResult();
         replyBuilder.UserGuid = msg.UserGuid;
         replyBuilder.RoomID = msg.RoomID;
         replyBuilder.TargetRoomID = msg.TargetRoomID;
         replyBuilder.Result = (int)SceneOperationResultEnum.Cant_Find_Room;
         channel.Send(replyBuilder);
     } else {
         RoomThread roomThread;
         if (isFieldThread) {
             roomThread = field_roomthread_list_[ix];
         } else {
             roomThread = roomthread_list_[ix];
         }
         bool targetIsFieldThread;
         int targetIx = GetActiveRoomThreadIndex(targetRoomId, out targetIsFieldThread);
         if (null != roomThread) {
             if (targetIx >= 0) {
                 //ͬ���г���
                 roomThread.QueueAction(roomThread.RemoveUser, guid, roomid, false, (MyAction<bool, int, User>)((bool success, int sceneId, User user) => {
                     if (success) {
                         PlayerGotoRoom(user, roomid, targetRoomId);
                     } else {
                         Msg_RL_ChangeSceneResult replyBuilder = new Msg_RL_ChangeSceneResult();
                         replyBuilder.UserGuid = guid;
                         replyBuilder.RoomID = roomid;
                         replyBuilder.TargetRoomID = targetRoomId;
                         replyBuilder.Result = (int)SceneOperationResultEnum.Cant_Find_Room;
                         channel.Send(replyBuilder);
                     }
                 }));
             } else {
                 //������
                 roomThread.QueueAction(roomThread.RemoveUser, guid, roomid, true, (MyAction<bool, int, User>)((bool success, int sceneId, User user) => {
                     if (success) {
                         Msg_RL_ChangeSceneResult replyBuilder = new Msg_RL_ChangeSceneResult();
                         EntityInfo info = user.Info;
                         if (null != info) {
                             replyBuilder.HP = info.Hp;
                             replyBuilder.MP = info.Energy;
                         }
                         replyBuilder.UserGuid = guid;
                         replyBuilder.RoomID = roomid;
                         replyBuilder.TargetRoomID = targetRoomId;
                         replyBuilder.Result = (int)SceneOperationResultEnum.Success;
                         channel.Send(replyBuilder);
                     } else {
                         Msg_RL_ChangeSceneResult replyBuilder = new Msg_RL_ChangeSceneResult();
                         replyBuilder.UserGuid = guid;
                         replyBuilder.RoomID = roomid;
                         replyBuilder.TargetRoomID = targetRoomId;
                         replyBuilder.Result = (int)SceneOperationResultEnum.Cant_Find_Room;
                         channel.Send(replyBuilder);
                     }
                 }));
             }
         }
     }
 }
        internal void OnChangeScene(List<ulong> userGuids, int sceneID)
        {
            bool failed = true;
            RoomInfo targetRoom = null;
            int roomId = m_LobbyInfo.FindSceneRoom(sceneID);
            if (roomId > 0) {
                targetRoom = m_LobbyInfo.GetRoomByID(roomId);
                if (null != targetRoom && targetRoom.UserCount + userGuids.Count <= targetRoom.TotalCount) {
                    for (int i = 0; i < userGuids.Count; ++i) {
                        ulong userGuid = userGuids[i];
                        UserInfo user = LobbyServer.Instance.UserProcessScheduler.GetUserInfo(userGuid);
                        if (user == null) { continue; }
                        if (null != user.Room) {
                            RoomInfo curRoom = user.Room;
                            if (curRoom.RoomId != targetRoom.RoomId) {
                                Msg_LR_ChangeScene msg = new Msg_LR_ChangeScene();
                                msg.UserGuid = userGuid;
                                msg.RoomID = curRoom.RoomId;
                                msg.TargetRoomID = targetRoom.RoomId;

                                LobbyServer.Instance.RoomSvrChannel.Send(curRoom.RoomServerName, msg);
                                LogSys.Log(LOG_TYPE.INFO, "User change field ! , guid:{0} room:{1} target room:{2}", userGuid, curRoom.RoomId, targetRoom.RoomId);
                                failed = false;
                            }
                        }
                    }
                }
            }
            if (failed) {
                for (int i = 0; i < userGuids.Count; ++i) {
                    ulong userGuid = userGuids[i];
                    UserInfo user = LobbyServer.Instance.UserProcessScheduler.GetUserInfo(userGuid);
                    if (null != user) {
                        LobbyServer.Instance.HighlightPrompt(user, 42);//进入游戏失败,请稍后重试
                    }
                }
            }
        }