/// <summary>
        /// Initializes a new <see cref="CardMovementAnimation"/>.
        /// </summary>
        public CardMovementAnimation(Card card, LerpInformation <Vector2> lerpInformation, CardPile targetPile)
        {
            Card            = card;
            LerpInformation = lerpInformation;
            TargetPile      = targetPile;

            lerpInformation.Finished += OnLerpFinished;
        }
Exemple #2
0
        /// <summary>
        /// Attempts to move a card onto the <paramref name="pile"/>.
        /// </summary>
        /// <param name="pile">The <see cref="CardPile"/> to move the current selection to.</param>
        /// <param name="ignoreMousePosition">Ignores whether the mouse is over the <paramref name="pile"/>.</param>
        private bool TryMoveCard(CardPile pile, bool ignoreMousePosition)
        {
            if (CurrentSelection == null || !pile.Contains(Input.MousePosition) && !ignoreMousePosition)
            {
                return(false);
            }

            // If we are trying to move a card from the tableau pile to
            // another pile, we need to make sure that it is the top card
            // that we are trying to move.
            if (CurrentSelection.CardPile is TableauPile &&
                CurrentSelection.Card != CurrentSelection.CardPile.Peek())
            {
                return(false);
            }

            if (!pile.CanPush(CurrentSelection.Card))
            {
                return(false);
            }

            // If we can move the card onto the pile, move it and clear the selection
            Card card = CurrentSelection.CardPile.Pop();
            LerpInformation <Vector2> animationLerp = new LerpInformation <Vector2>(card.Rectangle.GetValueOrDefault().Position,
                                                                                    pile.GetCardRectangle(card).Position, 0.15f, Vector2.Lerp);

            CardMovementAnimation cardMovementAnimation = new CardMovementAnimation(card, animationLerp, pile);

            cardMovementAnimations.Add(cardMovementAnimation);
            CurrentSelection = null;

            if (pile is FoundationPile)
            {
                foundationPileAddSoundEffect.Play();
            }

            return(true);
        }
Exemple #3
0
 /// <summary>
 /// Attempts to move a card onto the <paramref name="pile"/>.
 /// </summary>
 private bool TryMoveCard(CardPile pile) => TryMoveCard(pile, false);