예제 #1
0
파일: Player.cs 프로젝트: unix14/ShitHead
        public void SendStackCardsToPlayer(Player receivingPlayer, CardAnimator cardAnimator, List <byte> cardValues, bool isLocalPlayer)
        {
            List <Card> StackCards = cardAnimator.getStack();
            int         playerDisplayingCardsCount = StackCards.Count;

            if (playerDisplayingCardsCount < cardValues.Count)
            {
                Debug.LogError("Not enough stack cards");
                return;
            }

            for (int index = 0; index < cardValues.Count; index++)
            {
                Card card      = null;
                byte cardValue = cardValues[index];

                if (isLocalPlayer)
                {
                    foreach (Card c in StackCards)
                    {
                        if (c.Rank == Card.GetRank(cardValue) && c.Suit == Card.GetSuit(cardValue))
                        {
                            card = c;
                            break;
                        }
                    }
                }
                else
                {
                    card = StackCards[playerDisplayingCardsCount - 1 - index];
                    card.SetCardValue(cardValue);
                    card.SetFaceUp(true);
                }

                if (card != null)
                {
                    card.isInStack   = false;
                    card.isTouchable = true;

                    receivingPlayer.ReceiveDisplayingCard(card);
                    cardAnimator.AddCardAnimation(card, receivingPlayer.NextCardPosition(), index);

                    if (isLocalPlayer)
                    {
                        NumberOfDisplayingCards++;
                    }
                    else
                    {
                        receivingPlayer.NumberOfDisplayingCards++;
                    }
                }
                else
                {
                    Debug.LogError("Unable to find stack card.");
                }
            }
            cardAnimator.clearStack();
            RepositionDisplayingCards(cardAnimator);
        }