private void DrawCards()
        {
            bool isFaceup = true;//(Owner.State != PlayerState.Inactive);

            if (Owner is ComputerPlayer)
            {
                isFaceup = (Owner.State == CardLib.PlayerState.Loser || Owner.State == CardLib.PlayerState.Winner);
            }
            var cards       = Owner.GetCards();
            var chosenCards = Owner.GetChosenCards();

            if (cards == null || cards.Count == 0)
            {
                return;
            }

            for (var i = 0; i < cards.Count; i++)
            {
                var cardControl = new CardControl(cards[i]);
                if (PlayerOrientation == Orientation.Horizontal)
                {
                    if (chosenCards.Contains(cardControl.Card))
                    {
                        cardControl.Margin = new Thickness(i * 35, 25, 0, 0);
                    }
                    else
                    {
                        cardControl.Margin = new Thickness(i * 35, 35, 0, 0);
                    }
                }
                else
                {
                    if (chosenCards.Contains(cardControl.Card))
                    {
                        cardControl.Margin = new Thickness(10, 35 + i * 30, 0, 0);
                    }
                    else
                    {
                        cardControl.Margin = new Thickness(5, 35 + i * 30, 0, 0);
                    }
                }
                //cardControl.MouseDoubleClick += cardControl_MouseDoubleClick;
                cardControl.MouseLeftButtonDown += cardControl_Click;
                cardControl.IsFaceUp             = isFaceup;
                CardSurface.Children.Add(cardControl);
            }
        }
Esempio n. 2
0
        private void DrawDecks()
        {
            if ((AvailableCard == null || AvailableCard.Count == 0) && (CurrentPlayer != null && CurrentPlayer.Index != AvailableCardPlayer))   ////no change, no flush; clear when same user
            {
                return;
            }
            Console.WriteLine("Pass");
            controlCanvas.Children.Clear();
            if (CurrentPlayer == null || Deck == null || !GameStarted)
            {
                return;
            }

            List <CardControl> stackedCards = new List <CardControl>();//Deck.CardsInDeck

            for (int i = 0; i < Deck.CardsInDeck; i++)
            {
                stackedCards.Add(new CardControl(Deck.GetCard(i))
                {
                    Margin =
                        new Thickness(150 + (i * 1.25), 25 - (i * 1.25), 0, 0),
                    IsFaceUp = false
                });
            }

            if (stackedCards.Count > 0)
            {
                stackedCards.Last().MouseDoubleClick += Deck_MouseDoubleClick;
            }
            if (AvailableCard != null)
            {
                for (var i = 0; i < AvailableCard.Count; i++)
                {
                    var cardControl = new CardControl(AvailableCard[i]);
                    cardControl.Margin = new Thickness(i * 35, 35, 0, 0);
                    controlCanvas.Children.Add(cardControl);
                }
            }
            stackedCards.ForEach(x => controlCanvas.Children.Add(x));
        }