Beispiel #1
0
 public void DrawTableau(Graphics g, Tableau tableau)
 {
     foreach (Cascade cascade in tableau.Cascades)
     {
         DrawCascade(g, cascade);
     }
 }
Beispiel #2
0
        private void NewGame()
        {
            cells = new OpenCell[4];
            for (int i = 0; i < 4; i++)
            {
                int xc = Width / 2 - Width / 8 * (i + 1);
                cells[i]   = new OpenCell();
                cells[i].X = xc;
                cells[i].Y = 0;
            }

            foundations = new Foundation[4];
            for (int i = 0; i < 4; ++i)
            {
                foundations[i] = new Foundation(i, Width / 2 + Width / 8 * i, 0);
            }
            //deck = new deck();
            tableau = new Tableau(new deck(), 0, Card.CardHeight + 20, Width);

            gameData = new Stack <GameData>();

            selectedOrderedCascade = null;
            selectedCellWithCard   = null;

            // save initial game state, to be able to restart the game
            initialGameState = new GameData(tableau, foundations, cells, selectedOrderedCascade, selectedCellWithCard);
        }
Beispiel #3
0
 private void InitGameFromState(GameData state)
 {
     tableau                = state.Tableau;
     foundations            = state.Foundations;
     cells                  = state.Cells;
     selectedCellWithCard   = state.SelectedCellWithCard;
     selectedOrderedCascade = state.SelectedOrderedCascade;
 }
Beispiel #4
0
        public Tableau GetCopy()
        {
            Tableau t = new Tableau();

            foreach (Cascade cascade in cascades)
            {
                Cascade newCascade = cascade.GetCopy();
                t.cascades.AddLast(newCascade);
            }

            return(t);
        }
Beispiel #5
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);
            }
        }