示例#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())
                {
                    //开始战斗
                    //TODO
                    //通知房间内玩家 要进行战斗了 给客户端群发消息
                    room.Brocast(OpCode.MATCH, MatchCode.START_BRO, null);
                    //销毁房间
                    matchCache.Destroy(room);
                }
            });
        }
示例#2
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);
                }
            }
                );
        }
示例#3
0
        /// <summary>
        /// player ready
        /// </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.Broadcast(OpCode.MATCH, MatchCode.READY_BROADCAST, userId);

                //check:all player is ready
                if (room.IsAllReady())
                {
                    //start play card,deal cards
                    startFight(room.GetUIdList);
                    //send all player start play cards
                    room.Broadcast(OpCode.MATCH, MatchCode.START_BROADCAST, null);
                    //destroy room
                    matchCache.Destroy(room);
                }
            });
        }
示例#4
0
        /// <summary>
        /// 准备
        /// </summary>
        /// <param name="clientPeer"></param>
        private void ready(ClientPeer clientPeer)
        {
            SingleExecute.Instance.processSingle(
                () =>
            {
                if (!UserCache.Instance.IsOnline(clientPeer))
                {
                    return;
                }

                int uid             = UserCache.Instance.GetId(clientPeer);
                UserModel userModel = UserCache.Instance.GetModelByClientPeer(clientPeer);

                if (!MatchCache.Instance.IsMatching(uid))
                {
                    return;
                }

                MatchRoom room = MatchCache.Instance.GetRoom(uid);
                room.Ready(uid);
                //通知房间内除了自己以外的人,自己准备了
                room.Broadcast(OpCode.MATCH, MatchCode.READY_BOD, uid, clientPeer);
                Console.WriteLine("玩家" + userModel.Name + "在匹配房间:" + room.ID + "准备了");

                //如果所有人都准备了则开始游戏
                if (room.IsAllReady())
                {
                    //创建FightHandler
                    FightHandler.Instance.ToString();

                    /*if (StartGameEvent != null)
                     * {
                     *  StartGameEvent(room.ReadyUidlist);
                     * }*/
                    //创建战斗房间
                    FightRoom fightRoom = FightRoomCache.Instance.Create(room.ReadyUidlist);

                    //广播消息通知房间内所有人开始选择选择种族
                    room.Broadcast(OpCode.FIGHT, FightCode.SELECT_RACE_SBOD, "开始选择种族");

                    MatchCache.Instance.Destory(room);    //销毁匹配房间重用
                    return;
                }
            }
                );
        }
示例#5
0
        /// <summary>
        /// 客户端发来的准备请求
        /// </summary>
        /// <param name="client"></param>
        /// <param name="roomType"></param>
        private void Ready(ClientPeer client, int roomType)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (matchCacheList[roomType].IsMatching(client.Id) == false)
                {
                    return;
                }
                MatchRoom room = matchCacheList[roomType].GetRoom(client.Id);
                room.Ready(client.Id);
                room.Broadcase(OpCode.Match, MatchCode.Read_BRO, client.Id);

                //全部都准备了,可以开始游戏了
                if (room.IsAllReady())
                {
                    startFight(room.clientList, roomType);
                    //通知房间内的所有玩家开始游戏了
                    room.Broadcase(OpCode.Match, MatchCode.StartGame_BRO, null);
                    //销毁房间
                    matchCacheList[roomType].DestroyRoom(room);
                }
            });
        }