Esempio n. 1
0
 private void UnselectCellWithCard(bool removeCard)
 {
     if (selectedCellWithCard != null)
     {
         selectedCellWithCard.Top().IsSelected = false;
         if (removeCard)
         {
             selectedCellWithCard.Pop();
         }
         selectedCellWithCard = null;
     }
 }
Esempio n. 2
0
        public void DrawOpenCell(Graphics g, OpenCell cell)
        {
            Rectangle destRect = new Rectangle(cell.X, cell.Y, Card.CardWidth, Card.CardHeight);

            if (cell.Count == 0)
            {
                g.DrawImage(regCards, destRect, cardWidth * 2, CardHeight * 4, cardWidth, CardHeight, GraphicsUnit.Pixel);
            }
            else
            {
                DrawCard(g, cell.Top());
            }
        }
Esempio n. 3
0
        public bool TryAddCardFromCell(OpenCell cell)
        {
            Card card = cell.Top();

            if (card != null)
            {
                if (cards.Count == 0 || IsOrderedCards(cards.Last.Value, card))
                {
                    card.X = x;
                    card.Y = y + cards.Count * DeltaCardY;
                    cards.AddLast(card);

                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        public GameData(Tableau tableau, Foundation[] foundations, OpenCell[] cells, OrderedCascade selectedOrderedCascade, OpenCell selectedCell)
        {
            Cells = new OpenCell[cells.Length];
            for (int i = 0; i < 4; i++)
            {
                Cells[i]   = new OpenCell();
                Cells[i].X = cells[i].X;
                Cells[i].Y = cells[i].Y;
                Card card = cells[i].Top();
                if (card != null)
                {
                    Cells[i].Push(card.GetCopy());
                    if (selectedCell != null && card.IsEqual(selectedCell.Top()))
                    {
                        SelectedCellWithCard = Cells[i];
                    }
                }
            }

            Foundations = new Foundation[4];
            for (int i = 0; i < 4; ++i)
            {
                Foundations[i] = new Foundation(foundations[i].Suit, foundations[i].X, foundations[i].Y);
                Card card = foundations[i].Top();
                if (card != null)
                {
                    Foundations[i].Push(card.GetCopy());
                }
            }

            Tableau = tableau.GetCopy();

            if (selectedOrderedCascade != null)
            {
                SelectedOrderedCascade = Tableau.FindOrderedCascadeByCard(selectedOrderedCascade.Cards.First.Value);
            }
        }