예제 #1
0
        public override void update(GameTime gameTime)
        {
            snap.arrange(cards);

            foreach (Card card in cards)
            {
                if (card == null)
                {
                    continue;
                }

                card.update(gameTime);
            }
        }
예제 #2
0
        public override void update(GameTime gameTime)
        {
            base.update(gameTime);

            // Handle touches
            foreach (GestureSample gesture in GestureManager.Gestures)
            {
                switch (gesture.GestureType)
                {
                case GestureType.FreeDrag:
                {
                    if (dragTarget == null)
                    {
                        dragTarget = hand.getTopmostHit(gesture.Position);
                        if (dragTarget == null)
                        {
                            break;
                        }

                        dragTarget.halt();
                        dragTarget.Glow = true;
                        dragTarget.translate(gesture.Position - dragTarget.Position);
                        hand.bringToTop(dragTarget);
                    }
                    dragTarget.translate(gesture.Delta);
                    break;
                }

                case GestureType.DragComplete:
                {
                    if (dragTarget != null)
                    {
                        if (dropZone.checkForHit(lastGesture.Position))
                        {
                            dropZone.drop(dragTarget);
                        }
                        dragTarget.Glow = false;
                        hand.sort();
                        dragTarget = null;
                    }
                    break;
                }

                default:
                    break;
                }
                lastGesture = gesture;
            }

            // Move Cards
            if (dragTarget != null)
            {
                dragTarget.scaleTo(ScaleManager.CardScale * 1.2f, 10f);
            }

            List <Card> snapCards = new List <Card>(hand.getCards());

            if (dragTarget != null)
            {
                snapCards.Remove(dragTarget);
            }

            handSnap.arrange(snapCards);

            foreach (Card card in hand.getCards())
            {
                try { card.update(gameTime); } catch { }
            }
            table.update(gameTime);
        }