Beispiel #1
0
        /// <summary>
        /// 开始游戏
        /// </summary>
        /// <param name="fightRoom"></param>
        private void startGame(FightRoom fightRoom)//List<int> uidList)
        {
            SingleExecute.Instance.processSingle(
                () =>
            {
                //开始游戏广播
                fightRoom.Broadcast(OpCode.MATCH, MatchCode.START_GAME_BOD, "0");

                //创建牌库
                fightRoom.CreateCardLibrary();
                //初始化玩家手牌(发牌)
                fightRoom.InitPlayerCards();

                foreach (var item in fightRoom.playerDtos)
                {
                    //给每个客户端发送自己的手牌信息
                    List <CardDto> cardList = fightRoom.GetUserCard(item.UserID);
                    ClientPeer clientPeer   = UserCache.Instance.GetClientPeer(item.UserID);
                    clientPeer.StartSend(OpCode.FIGHT, FightCode.GET_CARD_SRES, cardList);
                }

                //由第一个进入房间的玩家首先开始回合
                PlayerDto firstPlayer = fightRoom.GetFirstPlayer();
                fightRoom.Broadcast(OpCode.FIGHT, FightCode.NEXT_TURN_SBOD, firstPlayer.UserID);
            }
                );
        }