/// <summary>
        /// 添加玩家 没有空位时检查游戏开始
        /// </summary>
        /// <param name="gamer"></param>
        public static void Add(this Moba5V5Room self, Gamer gamer)
        {
            int seatIndex = self.GetEmptySeat();

            //玩家需要获取一个座位坐下
            if (seatIndex >= 0)
            {
                self.gamers[seatIndex]   = gamer;
                self.isReadys[seatIndex] = false;
                self.seats[gamer.UserID] = seatIndex;
            }
            else
            {
                Log.Error("房间已满无法加入");
            }

            //房间满员时 通知客户端加载场景
            if (self.GetEmptySeat() == -1)
            {
                //为房间添加游戏组件
                if (self.GetComponent <MobaControllerComponent>() == null)
                {
                    self.AddComponent <MobaControllerComponent>().RoomReady();
                }
            }
        }
Exemple #2
0
        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("玩家不在正确的座位上");
                }
            }
        }