/// <summary>
        /// 向客户端发地主牌
        /// </summary>
        public static void CardsOnTable(this GameControllerComponent self, long id)
        {
            Room room = self.GetParent <Room>();
            OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>();
            HandCardsComponent       handCards       = room.GetGamerFromUserID(id).GetComponent <HandCardsComponent>();

            orderController.Start(id);

            for (int i = 0; i < 3; i++)
            {
                Card card = self.DealLord(room);
                handCards.AddCard(card);
            }

            //更新玩家身份
            foreach (var gamer in room.gamers)
            {
                Identity gamerIdentity = gamer.UserID == id ? Identity.Landlord : Identity.Farmer;
                self.UpdateInIdentity(gamer, gamerIdentity);
            }

            //广播地主消息
            room.Broadcast(new Actor_SetLandlord_Ntt()
            {
                UserID = id, LordCards = To.RepeatedField(room.LordCards)
            });

            //广播地主先手出牌消息
            room.Broadcast(new Actor_AuthorityPlayCard_Ntt()
            {
                UserID = id, IsFirst = true
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 发地主牌
        /// </summary>
        /// <param name="self"></param>
        /// <param name="id"></param>
        public static void CardsOnTable(this GameControllerComponent self, long id)
        {
            Room room = self.GetEntity <Room>();
            DeskCardsCacheComponent  deskCardsCache  = room.GetComponent <DeskCardsCacheComponent>();
            OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>();
            HandCardsComponent       handCards       = room.Get(id).GetComponent <HandCardsComponent>();

            orderController.Start(id);

            for (int i = 0; i < 3; i++)
            {
                Card card = deskCardsCache.Deal();
                handCards.AddCard(card);
            }

            //更新玩家身份
            foreach (var gamer in room.GetAll())
            {
                Identity gamerIdentity = gamer.Id == id ? Identity.Landlord : Identity.Farmer;
                self.UpdateInIdentity(gamer, gamerIdentity);
            }

            //广播地主消息
            room.Broadcast(new SelectLord()
            {
                PlayerId = id, LordCards = deskCardsCache.LordCards.ToArray()
            });

            //广播地主先手出牌消息
            room.Broadcast(new AuthorityPlayCard()
            {
                PlayerId = id, IsFirst = true
            });
        }
        /// <summary>
        /// 发地主牌
        /// </summary>
        /// <param name="self"></param>
        /// <param name="id"></param>
        public static void CardsOnTable(this GameControllerComponent self, long id)
        {
            Room room = self.GetParent <Room>();
            DeskCardsCacheComponent  deskCardsCache  = room.GetComponent <DeskCardsCacheComponent>();
            OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>();
            HandCardsComponent       handCards       = room.Get(id).GetComponent <HandCardsComponent>();

            orderController.Start(id);

            for (int i = 0; i < 3; i++)
            {
                Card card = deskCardsCache.Deal();
                handCards.AddCard(card);
            }

            //更新玩家身份
            foreach (var gamer in room.GetAll())
            {
                Identity gamerIdentity = gamer.UserID == id ? Identity.Landlord : Identity.Farmer;
                self.UpdateInIdentity(gamer, gamerIdentity);
            }

            //广播地主消息
            Actor_SetLandlord_Ntt SetLandlordMessage = new Actor_SetLandlord_Ntt()
            {
                UserID = id
            };

            SetLandlordMessage.LordCards.AddRange(deskCardsCache.LordCards);
            room.Broadcast(SetLandlordMessage);

            //广播地主先手出牌消息
            room.Broadcast(new Actor_AuthorityPlayCard_Ntt()
            {
                UserID = id, IsFirst = true
            });
        }