Example #1
0
        int GetChildIndex(CardIdentifier selectedCard)
        {
            int result = 0;
            for (int i=0; i < selectedCard.Level; i++)
                result += i;

            result += selectedCard.Position-1;

            return result;
        }
Example #2
0
        void UpdatePoints(List<List<Card>> tower, CardIdentifier selectedCard)
        {
            //update points
            var cardsLeft = tower.SelectMany(i => i).Where(t => t != null).ToList();
            var cardsLeftLevel = tower[selectedCard.Level].Where(t => t != null).ToList();

            var points = 0;
            var addition = inGame.Stage * 1.5;
            points = (int)(10 * addition);
            //inGame.Points += (int)(10 * addition);

            //## idea 1            
            //if (cardsLeft.Count == 0)
            //    inGame.Points += (int)(150.00 * addition);
            //else if (cardsLeftLevel.Count == 0)
            //    inGame.Points += (int)(20 * addition);
            //else
            //    inGame.Points += (int)(10 * addition);

            //## idea 2
            if (cardsLeftLevel.Count == 0)
            {
                switch (selectedCard.Level)
                {
                    case 2:
                        points += inGame.Level3Points;
                        inGame.Level3Count++;
                        break;
                    case 1:
                        points += inGame.Level2Points;
                        inGame.Level2Count++;
                        break;
                    case 0:
                        points += inGame.Level1Points;
                        inGame.Level1Count++;
                        break;
                    default:
                        break;
                }
            }

            inGame.TotalStagePoints += points;
            inGame.Points += points;
            
            txtPoints.Text = inGame.Points.ToString();

            MessageDialog d = new MessageDialog("Good job");
            if (CheckGameComplete())
            {
                inGame.StopTime = true;
                if (inGame.NextRoundCount > 0)
                {
                    DisplayFlyout_Bonus();
                }
                else
                {
                    ///await d.ShowAsync(); 
                    DisplayFlyout_NextRound();
                }

                if (!inGame.IsBonusStage)
                {
                    inGame.Stage++;
                }
            }
        }
Example #3
0
        void SetupTower(Canvas canvas, List<List<Card>> tower)
        {
            
            var index = 0;
            var levelIndex = 0;
            //#Setup towers
            foreach (var level in tower)
            {
                var position = 0;
                foreach (var card in level)
                {
                    var crd = new CardIdentifier() { CardIdentifierId = index, Level = levelIndex, Card = card, Position = position };
                    (canvas.Children[index] as Image).Tag = crd;
                    (canvas.Children[index] as Image).Margin = new Thickness(0);
                    
                    Uri uri = new Uri(string.Format("ms-appx:///Assets/Cards/{0}.png", card.Image));
                    (canvas.Children[index] as Image).Source = new BitmapImage(uri);

                    index++;
                    position++;
                }
                levelIndex++;
            }

        }
Example #4
0
        bool RemoveCard(List<List<Card>> tower, CardIdentifier selectedCard)
        {
            bool result = false;
            //apply the rules to remove a card
            var rule1 = cardOnHand.Number == 0 || selectedCard.Card.Number ==0 || 
                cardOnHand.Number == selectedCard.Card.Number + 1 || cardOnHand.Number == selectedCard.Card.Number - 1;
            var rule2 = tower.Count == selectedCard.Level+1 || 
                (tower[selectedCard.Level + 1][selectedCard.Position] == null && tower[selectedCard.Level + 1][selectedCard.Position + 1] == null);

            result = rule1 && rule2;

            return result; 
        }
Example #5
0
 private void SetupDeck(Canvas canvas, List<Card> deck)
 {
     var index = 0;
     //##Setup deck
     foreach (var card in deck)
     {
         var crd = new CardIdentifier() { CardIdentifierId = index, Level = 0, Card = card, Position = index };
         (canvas.Children[index] as Image).Tag = crd;
         (canvas.Children[index] as Image).Margin = new Thickness(0);
         index++;
     }
     inGame.CardsOnHand = index;
     txtCardsLeft.Text = inGame.CardsOnHand.ToString(); 
 }