예제 #1
0
        public StackCollapseAnimation(Board board, int stack, List <CardAnimationView> expandedCards)
        {
            _board = board;

            _startTime = DateTime.Now;

            var cardSize  = board.View.GetCardSize();
            int stackBase = board.GetStack(stack).Count - expandedCards.Count;

            _cardAnimations = new List <CardAnimationView>(expandedCards.Count);
            for (int i = 0; i < expandedCards.Count; i++)
            {
                var card = expandedCards[i].Card;
                card.View.Animating = true;

                var destPoint = board.View.GetLocationOfCardInStack(board.GetStack(stack), i + stackBase);

                var animation = new CardAnimationView(card, 0, Duration, expandedCards[i].CurrentRect.Location,
                                                      destPoint, cardSize.X, cardSize.Y);
                _cardAnimations.Add(animation);
            }

            _stopTime = DateTime.Now.AddSeconds(Duration);
            UpdateCardAnimations();
        }
예제 #2
0
        public ClearRunAnimation(Board board, int stack, Point destPoint)
        {
            Stack = stack;

            var cardSize  = board.View.GetCardSize();
            int stackSize = board.GetStack(stack).Count;

            _cardAnimations = new List <CardAnimationView>(13);
            for (int i = 0; i < 13; i++)
            {
                int pos  = stackSize - 13 + i;
                var card = board.GetStack(stack).GetCard(pos);
                card.View.Animating = true;
                var startPoint = board.View.GetLocationOfCardInStack(board.GetStack(stack), pos);

                var animation = new CardAnimationView(card, (13 - i) * Delay, Duration, startPoint, destPoint, cardSize.X, cardSize.Y);
                _cardAnimations.Add(animation);
            }

            _stopTime            = DateTime.Now.AddSeconds(13 * Delay + Duration);
            _completedAnimations = new List <CardAnimationView>(13);
            UpdateCardAnimations();
        }
예제 #3
0
        public DealAnimation(Board board, List <Card> cardsToDeal)
        {
            _board = board;

            _cardAnimations = new List <CardAnimationView>(Board.StackCount);

            // TODO: Revive this rule at some point?

            /*int cardCount = 0;
             * int stacksEmpty = 0;
             * for (int i = 0; i < Board.StackCount; i++)
             * {
             *      int stackSize = board.GetStack(i).Count;
             *      if (stackSize == 0)
             *              stacksEmpty++;
             *      cardCount += stackSize;
             * }
             *
             * if (stacksEmpty > 0 && cardCount >= Board.StackCount)
             * {
             *      string errorMsg = CardResources.Strings.GetString("EmptyStacksDealError");
             *      _board.View.AddError(errorMsg);
             *      return;
             * }*/

            int dealPos = board.CountOfExtraDealingsLeft() - 1;

            const double delay    = 0.1;
            const double duration = 0.2;

            var bounds     = board.View.GetViewArea();
            var cardSize   = board.View.GetCardSize();
            var startPoint = new Point(bounds.Width - cardSize.X - dealPos * 25, bounds.Height - cardSize.Y);

            for (int i = 0; i < cardsToDeal.Count; i++)
            {
                Card cardDealt = cardsToDeal[i];
                cardDealt.Reveal();
                cardDealt.View.Animating = true;

                Point destPoint = board.View.GetLocationOfCardInStack(board.GetStack(i), board.GetStack(i).Count);
                var   animation = new CardAnimationView(cardDealt, i * delay, duration, startPoint, destPoint, cardSize.X,
                                                        cardSize.Y);
                _cardAnimations.Insert(0, animation);
            }

            _stopTime = DateTime.Now.AddSeconds(cardsToDeal.Count * delay + duration);
            UpdateCardAnimations();
        }
예제 #4
0
        public CardStack GetStackAtPoint(Point pt)
        {
            int spacing = (_viewRect.Width - _cardSize.X * Board.StackCount) / (Board.StackCount - 1);
            int index   = pt.X / (_cardSize.X + spacing);

            if (index >= 0 && index < Board.StackCount)
            {
                Rectangle stackArea = GetAreaOfStack(_board.GetStack(index));
                if (stackArea.Contains(pt))
                {
                    return(_board.GetStack(index));
                }
            }
            return(null);
        }