Beispiel #1
0
        }                                               // called after cards are removed from _displayCards

        // adjust the rotations of an animation behavaior so that a card will end its rotations with the correct orientation for its destination
        private double ResolveRotations(CardGroup destinationGroup, AnimationBehavior animationBehavior)
        {
            double resolvedRotations = animationBehavior.Rotations;

            if ((this.OrientationDegress + animationBehavior.Rotations * 360) % 360 != destinationGroup.OrientationDegress)
            {
                var difference = destinationGroup.OrientationDegress - ((this.OrientationDegress + animationBehavior.Rotations * 360) % 360);
                resolvedRotations += difference / 360;
            }
            return(resolvedRotations);
        }
Beispiel #2
0
        public void TransferAll(CardGroup destinationGroup, AnimationBehavior animationBehavior)
        {
            var newPositions = destinationGroup.NextOpenPositions(_displayCards.Count);

            var cardsToTransfer = new List <UniqueDisplayCard>(_displayCards);

            this._displayCards.Clear();
            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);

            for (int i = 0; i < cardsToTransfer.Count; i++)
            {
                var cardToTransfer   = cardsToTransfer[i];
                var destinationPoint = newPositions[i].Item1;
                var newZIndex        = newPositions[i].Item2;

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

                // 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);
            }



            destinationGroup.OnPreCardsAddition(cardsToTransfer);
            destinationGroup._displayCards.AddRange(cardsToTransfer);
        }
Beispiel #3
0
        // 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);
        }
Beispiel #4
0
 // ensures that the card group passed in ends up in front of this card group
 // it does this by ensuring that the lowest z index of the passed in card group is higher than the highest z index of this card group
 public void BringCardGroupToFront(CardGroup groupToMove)
 {
     groupToMove._displayCards.ForEach(card => _canvasFacade.UpdateCard(card, zIndex: this._curZIndex + 1));
     groupToMove._curZIndex = this._curZIndex + 1;
 }