Ejemplo n.º 1
0
 public void Add(CardShape card)
 {
     cards.Add(card);
     card.DeckShape = this;
     Canvas.SetTop(card, CardSpace * 0);
     Canvas.SetLeft(card, 0);
     Canvas.SetZIndex(card, cards.Count + 1);
     LayoutRoot.Children.Add(card);
     Deck.TopCard = card.Card;
     card.Card.Deck = this.Deck;
 }
Ejemplo n.º 2
0
 public void Remove(CardShape card)
 {
     cards.Remove(card);
     LayoutRoot.Children.Remove(card);
     Deck.TakeTopCard();
 }
Ejemplo n.º 3
0
        void NewGame()
        {
            timer.Stop();
            gameShape.NewGame();
            TotalScore.Text = gameShape.Score.ToString();
            TotalMoves.Text = gameShape.MoveCount.ToString();
            dealer.Clear();
            stack.Clear();

            foreach (var d in ground)
            {
                d.Clear();
            }
            //Создаем карты
            Deck deal = new Deck();
            for (int i = 0; i < 2; i++)
            {
                for (int suit = 1; suit <= 4; suit++)
                {
                    for (int number = 1; number <= 13; number++)
                    {
                        Card c = new Card((CardRank)number, (CardSuit)suit);
                        deal.TopCard = c;
                    }
                }
                deal.Shuffle(5);
            }

            //Добавляем в основную колоду
            for (int i = 0; i < 104; i++)
            {
                CardShape cp = new CardShape();
                cp.Card = deal.TopCard;
                deal.TakeTopCard();
                cp.MouseLeftButtonDown += cp_MouseLeftButtonDown;
                //cp.MouseDoubleClick += cp_MouseDoubleClick;
                dealer.Add(cp);
            }

            // по 1 карты в стопку
            for (int i = 0; i < 3; i++)
            {
                bool visible = true;
                for (int j = 0; j < 7; j++)
                {
                    ground[(i * 7) + j].Add(dealer.TopCardShape);
                    ground[(i * 7) + j].Deck.TopCard.Visible = visible;
                    visible = !visible;
                }
            }

            for (int j = 0; j < ground.Count; j++)
            {
                ground[j].Deck.TopCard.Enabled = true;
                ground[j].Deck.TopCard.IsDragable = false;
            }

            dealer.Deck.MakeAllCardsDragable(false);
            dealer.Deck.TopCard.Visible = false;
            dealer.Deck.TopCard.IsDragable = false;
            Canvas.SetZIndex(dealer, 0);
            timer.Start();
        }