Ejemplo n.º 1
0
        void InitCards()
        {
            Card card1 = new Card() { Image="1c", Suit =  CardSuit.Spade, Number = 1 };
            Card card2 = new Card() { Image="2c", Suit =  CardSuit.Spade, Number = 2 };
            Card card3 = new Card() { Image="3c", Suit =  CardSuit.Spade, Number = 3 };
            Card card4 = new Card() { Image="4c", Suit =  CardSuit.Spade, Number = 4 };
            Card card5 = new Card() { Image="5c", Suit =  CardSuit.Spade, Number = 5 };
            Card card6 = new Card() { Image="6c", Suit =  CardSuit.Spade, Number = 6 };
            Card card7 = new Card() { Image="7c", Suit =  CardSuit.Spade, Number = 7 };
            Card card8 = new Card() { Image="8c", Suit =  CardSuit.Spade, Number = 8 };
            Card card9 = new Card() { Image="9c", Suit =  CardSuit.Spade, Number = 9 };
            Card card10 = new Card() { Image="10c", Suit =  CardSuit.Spade, Number = 10 };
            Card card11 = new Card() { Image="11c", Suit =  CardSuit.Spade, Number = 11 };
            Card card12 = new Card() { Image="12c", Suit =  CardSuit.Spade, Number = 12 };
            Card card13 = new Card() { Image="13c", Suit =  CardSuit.Spade, Number = 13 };

            Card card14 = new Card() { Image="1d", Suit =  CardSuit.Heart, Number = 1 };
            Card card15 = new Card() { Image="2d", Suit =  CardSuit.Heart, Number = 2 };
            Card card16 = new Card() { Image="3d", Suit =  CardSuit.Heart, Number = 3 };
            Card card17 = new Card() { Image="4d", Suit =  CardSuit.Heart, Number = 4 };
            Card card18 = new Card() { Image="5d", Suit =  CardSuit.Heart, Number = 5 };
            Card card19 = new Card() { Image="6d", Suit =  CardSuit.Heart, Number = 6 };
            Card card20 = new Card() { Image="7d", Suit =  CardSuit.Heart, Number = 7 };
            Card card21 = new Card() { Image="8d", Suit =  CardSuit.Heart, Number = 8 };
            Card card22 = new Card() { Image="9d", Suit =  CardSuit.Heart, Number = 9 };
            Card card23 = new Card() { Image="10d", Suit =  CardSuit.Heart, Number = 10 };
            Card card24 = new Card() { Image="11d", Suit =  CardSuit.Heart, Number = 11 };
            Card card25 = new Card() { Image="12d", Suit =  CardSuit.Heart, Number = 12 };
            Card card26 = new Card() { Image="13d", Suit =  CardSuit.Heart, Number = 13 };

            Card card27 = new Card() { Image="1h", Suit =  CardSuit.Diamond, Number = 1 };
            Card card28 = new Card() { Image="2h", Suit =  CardSuit.Diamond, Number = 2 };
            Card card29 = new Card() { Image="3h", Suit =  CardSuit.Diamond, Number = 3 };
            Card card30 = new Card() { Image="4h", Suit =  CardSuit.Diamond, Number = 4 };
            Card card31 = new Card() { Image="5h", Suit =  CardSuit.Diamond, Number = 5 };
            Card card32 = new Card() { Image="6h", Suit =  CardSuit.Diamond, Number = 6 };
            Card card33 = new Card() { Image="7h", Suit =  CardSuit.Diamond, Number = 7 };
            Card card34 = new Card() { Image="8h", Suit =  CardSuit.Diamond, Number = 8 };
            Card card35 = new Card() { Image="9h", Suit =  CardSuit.Diamond, Number = 9 };
            Card card36 = new Card() { Image="10h", Suit =  CardSuit.Diamond, Number = 10 };
            Card card37 = new Card() { Image="11h", Suit =  CardSuit.Diamond, Number = 11 };
            Card card38 = new Card() { Image="12h", Suit =  CardSuit.Diamond, Number = 12 };
            Card card39 = new Card() { Image="13h", Suit =  CardSuit.Diamond, Number = 13 };

            Card card40 = new Card() { Image="1s", Suit =  CardSuit.Club, Number = 1 };
            Card card41 = new Card() { Image="2s", Suit =  CardSuit.Club, Number = 2 };
            Card card42 = new Card() { Image="3s", Suit =  CardSuit.Club, Number = 3 };
            Card card43 = new Card() { Image="4s", Suit =  CardSuit.Club, Number = 4 };
            Card card44 = new Card() { Image="5s", Suit =  CardSuit.Club, Number = 5 };
            Card card45 = new Card() { Image="6s", Suit =  CardSuit.Club, Number = 6 };
            Card card46 = new Card() { Image="7s", Suit =  CardSuit.Club, Number = 7 };
            Card card47 = new Card() { Image="8s", Suit =  CardSuit.Club, Number = 8 };
            Card card48 = new Card() { Image="9s", Suit =  CardSuit.Club, Number = 9 };
            Card card49 = new Card() { Image="10s", Suit =  CardSuit.Club, Number = 10 };
            Card card50 = new Card() { Image="11s", Suit =  CardSuit.Club, Number = 11 };
            Card card51 = new Card() { Image="12s", Suit =  CardSuit.Club, Number = 12 };
            Card card52 = new Card() { Image="13s", Suit =  CardSuit.Club, Number = 13 };

            Card card53 = new Card() { Image="joker", Suit =  CardSuit.Joker, Number = 0 };
            Card card54 = new Card() { Image="joker", Suit =  CardSuit.Joker, Number = 0 };

            List<Card> tempCard = new List<Card>() { card1, card2, card3, card4, card5, card6, card7, card8, card9, card10,
                                                     card11, card12, card13, card14, card15, card16, card17, card18, card19, card20,
                                                     card21, card22, card23, card24, card25, card26, card27, card28, card29, card30,
                                                     card31, card32, card33, card34, card35, card36, card37, card38, card39, card40,
                                                     card41, card42, card43, card44, card45, card46, card47, card48, card49, card50,
                                                     card51, card52, card53, card54};

            //## Add a method to mix cards #//
            List<Card> level1_1 = new List<Card>() { GetRandomCards(ref tempCard) };
            List<Card> level1_2 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level1_3 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level1_4 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level1_5 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };

            List<Card> level2_1 = new List<Card>() { GetRandomCards(ref tempCard) };
            List<Card> level2_2 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level2_3 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level2_4 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level2_5 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };

            List<Card> level3_1 = new List<Card>() { GetRandomCards(ref tempCard) };
            List<Card> level3_2 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level3_3 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level3_4 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            List<Card> level3_5 = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };

            //List<Card> level1_1 = new List<Card>() { card1 };
            //List<Card> level1_2 = new List<Card>() { card2, card3 };
            //List<Card> level1_3 = new List<Card>() { card4, card5, card6 };
            //List<Card> level1_4 = new List<Card>() { card7, card8, card9, card10, };
            //List<Card> level1_5 = new List<Card>() { card11, card12, card13, card14, card15, };

            //List<Card> level2_1 = new List<Card>() { card16 };
            //List<Card> level2_2 = new List<Card>() { card17, card18, };
            //List<Card> level2_3 = new List<Card>() { card19, card20, card21 };
            //List<Card> level2_4 = new List<Card>() { card22, card23, card24, card25 };
            //List<Card> level2_5 = new List<Card>() { card26, card27, card28, card29, card30 };

            //List<Card> level3_1 = new List<Card>() { card31 };
            //List<Card> level3_2 = new List<Card>() { card32, card33 };
            //List<Card> level3_3 = new List<Card>() { card34, card35, card36 };
            //List<Card> level3_4 = new List<Card>() { card37, card38, card39, card40 };
            //List<Card> level3_5 = new List<Card>() { card41, card42, card43, card44, card45 };

            deck = new List<Card>() { GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard), GetRandomCards(ref tempCard) };
            //deck = new List<Card>() { card53, card53, card53, card53, card53, card53, card53, card53 };
            
            //Card on hand
            cardOnHand = GetRandomCards(ref tempCard);
            //cardOnHand = card53;
            //## ###################### #//

            //ListOfLevels
            tower1 = new List<List<Card>>() { level1_1, level1_2, level1_3, level1_4, level1_5 };
            tower2 = new List<List<Card>>() { level2_1, level2_2, level2_3, level2_4, level2_5 };
            tower3 = new List<List<Card>>() { level3_1, level3_2, level3_3, level3_4, level3_5 };

            Uri uri = new Uri(string.Format("ms-appx:///Assets/Cards/{0}.png", cardOnHand.Image));
            (rectCardOnHand as Image).Source = new BitmapImage(uri);
        }
Ejemplo n.º 2
0
        private void cardTower3_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (inGame.DisableCardClick || inGame.GameIsPaused)
                return;

            var card = (sender as Image);
            var selectedCard = card.Tag as CardIdentifier;
            var b = RemoveCard(tower3, selectedCard);
            if (b)
            {
                inGame.HitsInRowCount++;
                card.Margin = new Thickness(0, -1000, 0, 0);
                cardOnHand = selectedCard.Card;
                Uri uri = new Uri(string.Format("ms-appx:///Assets/Cards/{0}.png", selectedCard.Card.Image));
                Uri uriTower = null;

                var before = selectedCard.Position > 0 && tower3[selectedCard.Level][selectedCard.Position - 1] == null;
                var after = selectedCard.Position < tower3[selectedCard.Level].Count - 1 && tower3[selectedCard.Level][selectedCard.Position + 1] == null;

                if (before)
                {
                    uriTower = new Uri(string.Format("ms-appx:///Assets/Cards/{0}.png", tower3[selectedCard.Level - 1][selectedCard.Position - 1].Image));
                    (cnvThird.Children[GetChildIndex(selectedCard)] as Image).Source = new BitmapImage(uriTower);
                }
                if (after)
                {
                    uriTower = new Uri(string.Format("ms-appx:///Assets/Cards/{0}.png", tower3[selectedCard.Level - 1][selectedCard.Position].Image));
                    (cnvThird.Children[GetChildIndex(selectedCard) + 1] as Image).Source = new BitmapImage(uriTower);
                }

                tower3[selectedCard.Level][selectedCard.Position] = null;

                (rectCardOnHand as Image).Source = new BitmapImage(uri);

                UpdatePoints(tower3, selectedCard);

                CheckForBonus();
            }
        }
Ejemplo n.º 3
0
        private void cardDeck_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (inGame.DisableCardClick || inGame.GameIsPaused)
                return;

            var card = (sender as Image);
            var selectedCard = card.Tag as CardIdentifier;

            card.Margin = new Thickness(0, -1000, 0, 0);
            cardOnHand = selectedCard.Card;

            Uri uri = new Uri(string.Format("ms-appx:///Assets/Cards/{0}.png", cardOnHand.Image));
            (rectCardOnHand as Image).Source = new BitmapImage(uri);

            inGame.CardsOnHand--;
            txtCardsLeft.Text = inGame.CardsOnHand.ToString();

            inGame.HitsInRowCount = 0;
            //inGame.FreezeCount = inGame.NextRoundCount = 0;
            inGame.NextRoundCount = 0;
            //CheckForBonus();
        }
Ejemplo n.º 4
0
        Card GetRandomCards(ref List<Card> cards)
        {
            var nextRnd = random.NextDouble();
            var result = new Card();

            var index = (int)(cards.Count() * nextRnd);

            result = cards[index];
            cards.RemoveAt(index);

            return result;
        }