Esempio n. 1
0
        /// <summary>
        /// 准备
        /// </summary>
        /// <param name="client"></param>
        private void ready(ClientPeer client)
        {
            SingleExecute.Instance.Execute(
                () =>
            {
                if (userCache.IsOnline(client) == false)
                {
                    return;
                }
                int userId = userCache.GetId(client);
                if (matchCache.IsMatching(userId) == false)
                {
                    return;
                }
                //一定要注意安全的验证
                MatchRoom room = matchCache.GetRoom(userId);
                room.Ready(userId);
                //之前忘记了 &&&……%……&¥&¥&%#%#&¥&……%&
                room.Brocast(OpCode.MATCH, MatchCode.READY_BRO, userId);

                //检测:是否所有玩家都准备了
                if (room.IsAllReady())
                {
                    //开始战斗
                    startFight(room.GetUIdList());
                    //通知房间内的玩家  要进行战斗了 给客户端群发消息
                    room.Brocast(OpCode.MATCH, MatchCode.START_BRO, null);
                    //销毁房间
                    matchCache.Destroy(room);
                }
            }
                );
        }