Inheritance: global::ProtoBuf.IExtensible
コード例 #1
0
        //--------------------------------------
        private void HandleEnterScene(Msg_LR_EnterScene msg, PBChannel channel, int handle, uint seq)
        {
            ulong guid = msg.UserGuid;
            int roomId = msg.RoomID;
            bool isFieldThread;
            int ix = GetActiveRoomThreadIndex(roomId, out isFieldThread);
            if (ix < 0) {
                Msg_RL_EnterSceneResult replyBuilder = new Msg_RL_EnterSceneResult();
                replyBuilder.UserGuid = guid;
                replyBuilder.RoomID = roomId;
                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];
                }
                Msg_LR_RoomUserInfo rui = msg.UserInfo;

                User rsUser = user_pool_.NewUser();
                LogSys.Log(LOG_TYPE.INFO, "NewUser {0} for {1} {2}", rsUser.LocalID, rui.Guid, rui.Key);
                rsUser.Init();
                if (!rsUser.SetKey(rui.Key)) {
                    LogSys.Log(LOG_TYPE.WARN, "user who's key is {0} already in room!", rui.Key);
                    LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for {1} {2}, [RoomManager.HandleEnterScene]", rsUser.LocalID, rui.Guid, rui.Key);
                    user_pool_.FreeUser(rsUser.LocalID);

                    Msg_RL_EnterSceneResult replyBuilder = new Msg_RL_EnterSceneResult();
                    replyBuilder.UserGuid = guid;
                    replyBuilder.RoomID = roomId;
                    replyBuilder.Result = (int)SceneOperationResultEnum.User_Key_Exist;
                    channel.Send(replyBuilder);
                } else {
                    rsUser.LobbyUserData = rui;
                    if (rui.IsMachine == true)
                        rsUser.UserControlState = (int)UserControlState.Ai;
                    else
                        rsUser.UserControlState = (int)UserControlState.User;
                    if (msg.HP > 0 && msg.MP > 0) {
                        rsUser.SetHpArmor(msg.HP, msg.MP);
                    }

                    if (rui.EnterX > 0 && rui.EnterY > 0) {
                        rsUser.SetEnterPoint(rui.EnterX, rui.EnterY);
                    }

                    roomThread.QueueAction(roomThread.AddUser, rsUser, roomId, (MyAction<bool, int, User>)((bool success, int sceneId, User user) => {
                        if (success) {
                            Msg_RL_EnterSceneResult replyBuilder = new Msg_RL_EnterSceneResult();
                            replyBuilder.UserGuid = guid;
                            replyBuilder.RoomID = roomId;
                            replyBuilder.Result = (int)SceneOperationResultEnum.Success;
                            channel.Send(replyBuilder);
                        } else {
                            Msg_RL_EnterSceneResult replyBuilder = new Msg_RL_EnterSceneResult();
                            replyBuilder.UserGuid = guid;
                            replyBuilder.RoomID = roomId;
                            replyBuilder.Result = (int)SceneOperationResultEnum.Cant_Find_Room;
                            channel.Send(replyBuilder);
                        }
                    }));
                }
            }
        }
コード例 #2
0
        private void RequestEnterSceneRoom(UserInfo info, int roomId, int hp, int mp, float x, float y)
        {
            RoomInfo room = m_LobbyInfo.GetRoomByID(roomId);
            if (null != room) {
                int campId = (int)CampIdEnum.Blue;
                TableConfig.Level cfg = TableConfig.LevelProvider.Instance.GetLevel(room.SceneType);
                if (null != cfg) {
                    campId = (int)CampIdEnum.FreedomCamp_Begin + info.WorldId;//room.GenNextCampId();
                }
                room.AddUsers(campId, info.Guid);
                Msg_LR_EnterScene enterSceneMsg = new Msg_LR_EnterScene();
                enterSceneMsg.UserGuid = info.Guid;
                enterSceneMsg.RoomID = roomId;

                Msg_LR_RoomUserInfo ruiBuilder = info.RoomUserInfo;
                ruiBuilder.Key = info.Key;
                ruiBuilder.Camp = info.CampId;
                if (hp > 0 && mp > 0) {
                    enterSceneMsg.HP = hp;
                    enterSceneMsg.MP = mp;
                }
                if (x > 0 && y > 0) {
                    ruiBuilder.EnterX = x;
                    ruiBuilder.EnterY = y;
                }
                enterSceneMsg.UserInfo = ruiBuilder;

                LobbyServer.Instance.RoomSvrChannel.Send(room.RoomServerName, enterSceneMsg);

                LogSys.Log(LOG_TYPE.DEBUG, "Request enter field, user {0} room {1}", info.Guid, roomId);
            }
        }