/// <summary> /// 移除玩家 /// </summary> /// <param name="id"></param> public void RemoveGamer(long id) { Gamer gamer = GetParent <UI>().GetComponent <GamerComponent>().Remove(id); // gamer?.GetComponent<GamerUIComponent>()?.Panel?.SetActive(false); gamer?.Dispose(); }
protected override void Run(Session session, MP2MH_PlayerExitRoom_Req message, Action <MH2MP_PlayerExitRoom_Ack> reply) { MH2MP_PlayerExitRoom_Ack response = new MH2MP_PlayerExitRoom_Ack(); try { MatchRoomComponent matchRoomComponent = Game.Scene.GetComponent <MatchRoomComponent>(); Room room = matchRoomComponent.Get(message.RoomID); //移除玩家对象 Gamer gamer = room.Remove(message.UserID); Game.Scene.GetComponent <MatchComponent>().Playing.Remove(gamer.UserID); gamer.Dispose(); Log.Info($"Match:同步玩家{message.UserID}退出房间"); if (room.Count == 0) { //当房间中没有玩家时回收 matchRoomComponent.Recycle(room.Id); Log.Info($"回收房间{room.Id}"); } reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
public static void ClearRoom(this Room self) { // RoomComponent roomComponet = Game.Scene.GetComponent<RoomComponent>(); for (int i = 0; i < self.gamers.Count; i++) { Gamer gamer = self.gamers[i]; // roomComponet.rooms.Remove(rooms.roomId); gamer.Dispose(); self.Dispose(); } }
public void RemoveGamer(long id) { int seatIndex = GetGamerSeat(id); if (seatIndex >= 0) { Gamer gamer = gamers[seatIndex]; gamers[seatIndex] = null; seats.Remove(id); gamer.Dispose(); } }
/// <summary> /// 移除玩家 /// </summary> /// <param name="id"></param> public void RemoveGamer(long id) { Gamer gamer = GetParent <UI>().GetComponent <GamerComponent>().Remove(id); gamer.Dispose(); }