コード例 #1
0
ファイル: CardGroup.cs プロジェクト: comoody/WizardMobile
        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);
        }
コード例 #2
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);
        }