コード例 #1
0
ファイル: CardGroup.cs プロジェクト: comoody/WizardMobile
        // sets the given card to have the highest z Index in the card group, thus displaying it on top of any other card it may overlap with
        // returns true if successfully found and updated, false otherwise
        public bool BringCardToFront(Core.Card card)
        {
            var displayCardIndex = _displayCards.FindIndex(displayCard => displayCard.CoreCard == card);

            if (displayCardIndex != -1)
            {
                // bring to front switches the current card with the last card in displayCards and updates the zIndex accordingly (left to right)
                // if the current card is already at the end of the list, it already has the highest zIndex - otherwise, reorder the cards
                if (displayCardIndex < _displayCards.Count - 1)
                {
                    var temp = _displayCards.Last();
                    _displayCards[_displayCards.Count - 1] = _displayCards[displayCardIndex];
                    _displayCards[displayCardIndex]        = temp;

                    // iterate through all cards and assign them sequential zIndex values except for the passed in card, which is assigned the
                    // highest zIndex of _curZIndex
                    int zCount = 0;
                    for (int i = 0; i < _displayCards.Count; i++)
                    {
                        int curZIndex = i == displayCardIndex ? _curZIndex : zCount++;
                        _canvasFacade.UpdateCard(_displayCards[i], zIndex: zCount);
                    }
                }
                return(true);
            }
            return(false);
        }
コード例 #2
0
        public void PopulateDeck(string[] cardNames, string dbFilename)
        {
            Core.CardDatabase db = new Core.CardDatabase(dbFilename);

            CardTypes = new CardTypeHelper[] {
                new CardTypeHelper {
                    Type = "Creature", CardList = new List <Core.Card>(), Count = 0
                },
                new CardTypeHelper {
                    Type = "Land", CardList = new List <Core.Card>(), Count = 0
                },
                new CardTypeHelper {
                    Type = "Planeswalker", CardList = new List <Core.Card>(), Count = 0
                },
                new CardTypeHelper {
                    Type = "Enchantment", CardList = new List <Core.Card>(), Count = 0
                },
                new CardTypeHelper {
                    Type = "Artifact", CardList = new List <Core.Card>(), Count = 0
                },
                new CardTypeHelper {
                    Type = "Sorcery", CardList = new List <Core.Card>(), Count = 0
                },
                new CardTypeHelper {
                    Type = "Instant", CardList = new List <Core.Card>(), Count = 0
                }
            };

            var uniqueCards = from c in cardNames
                              group c by c into cardGroup
                              select new {
                Name  = cardGroup.Key,
                Count = cardGroup.Count()
            };

            foreach (var card in uniqueCards)
            {
                Core.Card cardToAdd = db.GetCardByName(card.Name);

                if (cardToAdd != null)
                {
                    cardToAdd.Count = card.Count;

                    foreach (var cardType in CardTypes)
                    {
                        if (cardToAdd.Type.Contains(cardType.Type))
                        {
                            cardType.Count += cardToAdd.Count;
                            cardType.CardList.Add(cardToAdd);
                        }
                    }
                }
            }

            return;
        }
コード例 #3
0
ファイル: CardGroup.cs プロジェクト: comoody/WizardMobile
        public void Add(Core.Card card, bool isCardFaceUp = false)
        {
            UniqueDisplayCard displayCard = new UniqueDisplayCard(card, isCardFaceUp);
            var nextOpenPositionInfo      = NextOpenPositions(1)[0];

            OnPreCardsAddition(new List <UniqueDisplayCard> {
                displayCard
            });
            _displayCards.Add(displayCard);

            _canvasFacade.AddCard(displayCard, nextOpenPositionInfo.Item1 /*pos*/, OrientationDegress, nextOpenPositionInfo.Item2 /*zIndex*/);
        }
コード例 #4
0
ファイル: CardGroup.cs プロジェクト: comoody/WizardMobile
        // removes the first card in _cards matching the card param
        // animates removal
        public bool Remove(Core.Card card)
        {
            UniqueDisplayCard cardToRemove = GetDisplayCardFromCoreCard(card);

            if (cardToRemove != null)
            {
                _displayCards.Remove(cardToRemove);
                _canvasFacade.RemoveCard(cardToRemove);
                OnPostCardsRemoval();
                return(true);
            }
            return(false);
        }
コード例 #5
0
ファイル: CardGroup.cs プロジェクト: comoody/WizardMobile
        // transfers the first card in _cards matching the cardName param
        public bool Transfer(Core.Card card, CardGroup destinationGroup, AnimationBehavior animationBehavior)
        {
            UniqueDisplayCard cardToTransfer = GetDisplayCardFromCoreCard(card);

            if (cardToTransfer != null)
            {
                var nextOpenPositionInfo = destinationGroup.NextOpenPositions(1)[0];
                var destinationPoint     = nextOpenPositionInfo.Item1;
                var newZIndex            = nextOpenPositionInfo.Item2;

                this._displayCards.Remove(cardToTransfer);
                this.OnPostCardsRemoval();

                // resolve rotations so that the animation terminates at the angle of the destination group
                // rotations are rounded up so that the card is flush with the destination
                double resolvedRotations = ResolveRotations(destinationGroup, animationBehavior);

                var transferAnimRequest = new NamedAnimationRequest()
                {
                    Destination       = destinationPoint,
                    Duration          = animationBehavior.Duration,
                    Delay             = animationBehavior.Delay,
                    Rotations         = resolvedRotations,
                    TargetElementName = cardToTransfer.Id
                };
                _canvasFacade.QueueAnimationRequest(transferAnimRequest);

                destinationGroup.OnPreCardsAddition(new List <UniqueDisplayCard> {
                    cardToTransfer
                });
                destinationGroup._displayCards.Add(cardToTransfer);

                // finish transfer to destination group by updating the card to have the correct zIndex as determined by its destination group
                _canvasFacade.UpdateCard(cardToTransfer, zIndex: newZIndex);
                return(true);
            }
            return(false);
        }
コード例 #6
0
ファイル: CardGroup.cs プロジェクト: comoody/WizardMobile
        // flips a card in place to either face up or face down
        public bool Flip(Core.Card card)
        {
            UniqueDisplayCard cardToFlip = GetDisplayCardFromCoreCard(card);

            return(FlipImpl(cardToFlip));
        }
コード例 #7
0
ファイル: CardGroup.cs プロジェクト: comoody/WizardMobile
 // returns the first display card matching the core card passed in without unique mapping of core cards to display cards
 // if two different wizard core cards are passed in, they will return the same display card.
 // to get unique mapping of core card to display card, use GetDisplayCardsFromCoreCards
 protected UniqueDisplayCard GetDisplayCardFromCoreCard(Core.Card card)
 {
     return(_displayCards.Find(displayCard => displayCard.CoreCard.Equals(card)));
 }