internal void LeaveScene(User user) { EntityInfo info = user.Info; RemoveCareList(info); m_StorySystem.SendMessage("user_leave_scene", info.GetId(), info.GetUnitId(), info.GetCampId(), info.GetMovementStateInfo().PositionX, info.GetMovementStateInfo().PositionZ); user.SetHpArmor(info.Hp, info.Energy); user.HaveEnterPosition = false; user.IsEntered = false; info.NeedDelete = true; user.Info = null; }
public void LeaveScene(User user) { user.HaveEnterPosition = false; user.IsEntered = false; EntityInfo info = user.Info; if (null != info) { RemoveCareList(info); var args = m_StorySystem.NewBoxedValueList(); args.Add(info.GetId()); args.Add(info.GetUnitId()); args.Add(info.GetCampId()); args.Add(info.GetMovementStateInfo().PositionX); args.Add(info.GetMovementStateInfo().PositionZ); m_StorySystem.SendMessage("user_leave_scene", args); user.SetHpArmor(info.Hp, info.Energy); info.NeedDelete = true; user.Info = null; } }
//-------------------------------------- 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); } })); } } }