Пример #1
0
        /// <summary>
        /// 清空牌桌
        /// </summary>
        /// <param name="self"></param>
        public static void Clear(this DeskCardsCacheComponent self)
        {
            DeckComponent deck = self.Entity.GetComponent <DeckComponent>();

            while (self.CardsCount > 0)
            {
                Card card = self.library[self.CardsCount - 1];
                self.library.Remove(card);
                deck.AddCard(card);
            }

            self.Rule = CardsType.None;
        }
        /// <summary>
        /// 场上所有牌回收到牌库中
        /// </summary>
        /// <param name="self"></param>
        public static void BackToDeck(this GameControllerComponent self)
        {
            Room          room          = self.GetParent <Room>();
            DeckComponent deckComponent = room.GetComponent <DeckComponent>();

            foreach (var gamer in room.GetAll())
            {
                HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                while (handCards.CardsCount > 0)
                {
                    byte card = handCards.library[handCards.CardsCount - 1];
                    handCards.PopCard(card);
                    deckComponent.AddCard(card);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 场上的所有牌回到牌库中
        /// </summary>
        /// <param name="self"></param>
        public static void BackToDeck(this GameControllerComponent self)
        {
            Room                    room           = self.GetEntity <Room>();
            DeckComponent           deckComponent  = room.GetComponent <DeckComponent>();
            DeskCardsCacheComponent deskCardsCache = room.GetComponent <DeskCardsCacheComponent>();

            //回收牌桌卡牌
            deskCardsCache.Clear();
            deskCardsCache.LordCards.Clear();

            //回收玩家手牌
            foreach (var gamer in room.GetAll())
            {
                HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                while (handCards.CardsCount > 0)
                {
                    Card card = handCards.Library[handCards.CardsCount - 1];
                    handCards.PopCard(card);
                    deckComponent.AddCard(card);
                }
            }
        }