/// <summary> /// 返回玩家是否已准备 玩家不在房间时返回false /// </summary> /// <param name="self"></param> /// <param name="gamer"></param> /// <returns></returns> public static bool IsGamerReady(this Moba5V5Room self, Gamer gamer) { int seatIndex = self.GetGamerSeat(gamer.UserID); if (seatIndex > 0) { return(self.isReadys[seatIndex]); } return(false); }
/// <summary> /// 获取房间中的玩家 /// </summary> /// <param name="id"></param> /// <returns></returns> public static Gamer GetGamerFromUserID(this Moba5V5Room self, long id) { int seatIndex = self.GetGamerSeat(id); if (seatIndex >= 0) { return(self.gamers[seatIndex]); } return(null); }
/// <summary> /// 移除玩家并返回 玩家离开房间 /// </summary> /// <param name="id"></param> /// <returns></returns> public static Gamer Remove(this Moba5V5Room self, long id) { int seatIndex = self.GetGamerSeat(id); if (seatIndex >= 0) { Gamer gamer = self.gamers[seatIndex]; self.gamers[seatIndex] = null; self.seats.Remove(id); return(gamer); } return(null); }
protected override void Run(Gamer gamer, A1007_GamerReadyMoba5V5_C2M message) { Moba5V5Component moba = Game.Scene.GetComponent <Moba5V5Component>(); Moba5V5Room room = moba.GetWaitingRoom(gamer); if (room != null) { //找到玩家的座位顺序 设置其准备状态为真 int seatIndex = room.GetGamerSeat(gamer.UserID); if (seatIndex >= 0) { room.isReadys[seatIndex] = true; //检测开始游戏 room.GetComponent <MobaControllerComponent>().CheckGameStart(); } else { Log.Error("玩家不在正确的座位上"); } } }