Ejemplo n.º 1
0
        private List <CardViewmodel> AssignCardsToGameGrid(Grid gameGrid, List <CardViewmodel> initialCardCollection)
        {
            List <CardViewmodel> gameCardCollection = new List <CardViewmodel>();

            for (int row = 0; row < 6; row++)
            {
                for (int col = 0; col < 6; col++)
                {
                    Rectangle rectangle = gameGrid.Children.OfType <Rectangle>().Single(
                        x =>
                        (int)x.GetValue(Grid.RowProperty) == row &&
                        (int)x.GetValue(Grid.ColumnProperty) == col);

                    int randomCardNumber = random.Next(0, initialCardCollection.Count);

                    CardViewmodel card = initialCardCollection[randomCardNumber];

                    gameCardCollection.Add(card);
                    rectangle.DataContext = card;

                    initialCardCollection.RemoveAt(randomCardNumber);
                    Wait(200);
                }
            }

            return(gameCardCollection);
        }
Ejemplo n.º 2
0
        protected void FlipCard(Rectangle cardRectangle)
        {
            CardViewmodel card = cardRectangle.DataContext as CardViewmodel;

            FlipCardRectangle(cardRectangle, 1, 0);

            card.ModelStatus.Flip();

            FlipCardRectangle(cardRectangle, 0, 1);
        }
Ejemplo n.º 3
0
        protected List <CardViewmodel> CreateCards()
        {
            List <CardViewmodel> cards = new List <CardViewmodel>();

            BitmapImage backgroundImage = GetImage("images/background.jpg");

            for (int x = 1; x < 19; x++)
            {
                BitmapImage   frontImage = GetImage(String.Format("images/{1}/R{0}.png", x, iconSet));
                CardViewmodel a          = new CardViewmodel(x.ToString(), frontImage, backgroundImage);

                frontImage = GetImage(String.Format("images/{1}/R{0}.png", x, iconSet));
                CardViewmodel b = new CardViewmodel(x.ToString(), frontImage, backgroundImage);

                cards.Add(a);
                cards.Add(b);
            }

            return(cards);
        }
Ejemplo n.º 4
0
        protected void MatchCard(Rectangle rectangle)
        {
            CardViewmodel card = rectangle.DataContext as CardViewmodel;

            card.Match();
        }
Ejemplo n.º 5
0
 protected virtual void OnCardPicked(CardViewmodel card)
 {
 }