public async Task Handle(MovedEvent message, CancellationToken cancellationToken) { var player = message.Player; var roomIn = message.RoomIn; var roomOut = message.RoomOut; //更新玩家在线数据 await _chatOnlineProvider.SetPlayerOnline(new PlayerOnlineModel { IsOnline = true, LastDate = DateTime.Now, Level = player.Level, PlayerName = player.Name, PlayerId = player.Id, RoomId = player.RoomId, Gender = player.Gender, Title = player.Title }); //更新玩家聊天房间 await _mudProvider.RemoveFromRoom(player.Id, roomOut.Id); await _mudProvider.AddToRoom(player.Id, roomIn.Id); //更新新房间玩家列表 var playersIn = await _chatOnlineProvider.GetPlayerList(roomIn.Id); await _mudProvider.UpdateRoomPlayerList(roomIn.Id, playersIn); //更新旧房间玩家列表 var playersOut = await _chatOnlineProvider.GetPlayerList(roomOut.Id); await _mudProvider.UpdateRoomPlayerList(roomOut.Id, playersOut); var roomModel = _mapper.Map <RoomModel>(roomIn); await _mudProvider.Move(player.Id, roomModel); //更新当前玩家显示的npc列表 var nps = (await _npcDomainService.GetAll()).Where(x => x.RoomId == roomIn.Id); await _mudProvider.UpdatePlayerRoomNpcList(player.Id, nps); //输出移动信息 await _mudProvider.ShowMessage(player.Id, $"你来到了{roomIn.Name}。"); await _mudProvider.ShowRoomOthersMessage(roomIn.Id, player.Id, $"[{player.Name}] 从{roomOut.Name}走了过来。"); await _mudProvider.ShowRoomOthersMessage(roomOut.Id, player.Id, $"[{player.Name}] 往{roomIn.Name}离开。"); }
public async Task Handle(NpcMovedEvent message, CancellationToken cancellationToken) { var npc = message.Npc; var roomIn = message.RoomIn; var roomOut = message.RoomOut; //更新当前玩家显示的npc列表 var roomInNpcs = (await _npcDomainService.GetAll()).Where(x => x.RoomId == roomIn.Id); var roomOutNpcs = (await _npcDomainService.GetAll()).Where(x => x.RoomId == roomOut.Id); await _mudProvider.UpdateRoomNpcList(roomIn.Id, roomInNpcs); await _mudProvider.UpdateRoomNpcList(roomOut.Id, roomOutNpcs); //输出移动信息 await _mudProvider.ShowRoomMessage(roomOut.Id, $"[{npc.Name}] 往{roomIn.Name}离开。"); await _mudProvider.ShowRoomMessage(roomIn.Id, $"[{npc.Name}] 从{roomOut.Name}走了过来。"); }
public async Task <Paging <NpcEntity> > GetPaging(string keyword, int pageIndex) { var query = await _npcDomainService.GetAll(); if (!string.IsNullOrEmpty(keyword)) { query = query.Where(x => x.Name.Contains(keyword)); } var paging = await query.Paged(pageIndex); return(paging); }