Пример #1
0
        /// <summary>
        /// 开始战斗
        /// </summary>
        public void StartFight(List <int> uidList)
        {
            SingleExecute.Instance.Execute(
                delegate()
            {
                //创建战斗房间
                FightRoom room = fightCache.Create(uidList);
                room.InitPlayerCards();
                room.Sort();
                //发送给每个客户端 他自身有什么牌
                foreach (int uid in uidList)
                {
                    ClientPeer client       = userCache.GetClientPeer(uid);
                    List <CardDto> cardList = room.GetUserCards(uid);
                    //int[] cardIds = new int[17];
                    //54 每一张牌 都是一个 id
                    //红桃A 是 0
                    //红桃2 是 1
                    //红桃3 是 2
                    //红桃4 是 3
                    //红桃5 是 4
                    //发送的int数组 是 234
                    client.Send(OpCode.FIGHT, FightCode.GET_CARD_SRES, cardList);
                }
                //发送开始抢地主的响应
                int firstUserId = room.GetFirstUId();

                brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, firstUserId, null);
            });
        }
Пример #2
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);
            }
                );
        }
Пример #3
0
        /// <summary>
        /// 开始战斗
        /// </summary>
        public void startFight(List <int> uidList)
        {
            SingleExecute.Instance.Execute(() =>
            {
                //创建战斗房间
                FightRoom room = fightCache.Create(uidList);
                room.InitPlayerCards();
                room.Sort();
                //发送给每个客户端 他自身有什么牌
                foreach (int uid in uidList)
                {
                    ClientPeer client       = userCache.GetClientPeer(uid);
                    List <CardDto> cardList = room.getUserCards(uid);
                    client.Send(OpCode.FIGHT, FightCode.GET_CARD_SRES, cardList);
                }

                //开始抢地主
                int firstUserId = room.GetFirstUId();
                Brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, firstUserId, null);
            });
        }
Пример #4
0
        /// <summary>
        /// start play cards
        /// </summary>
        /// <param name="userIdList"></param>
        public void startFight(List <int> userIdList)
        {
            SingleExecute.Instance.Execute(() =>
            {
                //create fight room
                FightRoom room = fightCache.Create(userIdList);
                room.InitPlayerCards();
                room.Sort();
                //send all client ,what cards he have;
                foreach (int uid in userIdList)
                {
                    ClientPeer client       = userCache.GetClientPeer(uid);
                    List <CardDto> cardList = room.getUserCards(uid);
                    client.Send(OpCode.FIGHT, FightCode.GET_CARD_SRES, cardList);
                }

                //start grab landlord
                int firstUserId = room.GetFirstUserId();
                //tell all client firstUserId user to grab landlord
                Broadcast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BROADCAST, firstUserId, null);
            });
        }
Пример #5
0
 /// <summary>
 /// 开始战斗
 /// </summary>
 public void startFight(List <int> uIdList)
 {
     SingleExecute.Instance.Execute(
         delegate()
     {
         //创建战斗房间
         FightRoom room = fightCache.Create(uIdList);
         room.InitPlayerCards();
         room.Sort();
         //发送设置按钮响应
         brocast(room, OpCode.FIGHT, FightCode.BUTTON_BRO, null);
         //发送给每个客户端 它自身有什么用
         foreach (int uid in uIdList)
         {
             ClientPeer client       = userCache.GetClientPeer(uid);
             List <CardDto> cardList = room.GetUserCards(uid);
             client.Send(OpCode.FIGHT, FightCode.GET_CARD_SRES, cardList);
         }
         //发送开始抢地主的响应
         int firstUserId = room.GetFirstUId();
         brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, firstUserId, null);
     });
 }
Пример #6
0
 /// <summary>
 /// 开始战斗
 /// </summary>
 /// <param name="uIdList"></param>
 public void StartFight(List <int> uIdList)
 {
     SingleExecute.Instance.Execute
     (
         delegate()
     {
         //创建战斗房间
         FightRoom room = fight.CreatRoom(uIdList);
         //创建牌  并排序
         room.InitPlayerCards();
         room.Sort();
         //发送给每个客户端 自身有什么牌
         foreach (int uId in uIdList)
         {
             ClientPeer client       = user.GetClientById(uId);
             List <CardDto> cardList = room.GetPlayerCard(uId);
             client.Send(OpCode.FIGHT, FightCode.GET_CARD_SRES, cardList);
         }
         //发送开始抢地主响应
         int firstUserId = room.GetFirstUid();
         Brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB__BRO, firstUserId, null);
     }
     );
 }