Ejemplo n.º 1
0
        public void PlaceInSlot(CardSlot slot, TimeSpan delay)
        {
            Storyboard placeAnimation = Resources["PlaceStoryboard"] as Storyboard;

            GeneralTransform transform = slot.TransformToVisual(this);

            Point point = transform.Transform(new Point(0, 0));

            (placeAnimation.Children[0] as DoubleAnimation).To = point.X;
            (placeAnimation.Children[1] as DoubleAnimation).To = point.Y + slot.StackVerticalOffset;

            placeAnimation.BeginTime = delay;

            double rotateToAngle = 0;

            if (slot.RenderTransform is RotateTransform) {
                rotateToAngle = (slot.RenderTransform as RotateTransform).Angle;

                //(placeAnimation.Children[1] as DoubleAnimation).To -= slot.StackVerticalOffset;
            }

            (placeAnimation.Children[2] as DoubleAnimation).To = rotateToAngle;

            placeAnimation.Completed += delegate {
                placeAnimation.Stop();

                IsActivating = false;

                /*
                Card newCard = new Card() {
                    ContainingSlot = slot,
                    DataContext = this.DataContext
                };

                //newCard.Activated += Activated;
                //newCard.Placed
                if (HasFrontSideUp) {
                    newCard.Flip(animated: false);
                }

                slot.Add(newCard);
                */

                slot.Add(this);

                OnPlaced(slot, ContainingSlot);

                ContainingSlot = slot;
            };

            IsHitTestVisible = false;

            placeAnimation.Begin();
        }
Ejemplo n.º 2
0
 void OnPlaced(CardSlot toSlot, CardSlot fromSlot)
 {
     if (Placed != null) {
         Placed(this, new CardPlacedEventArgs(toSlot, fromSlot));
     }
 }
 public CardPlacedEventArgs(CardSlot intoSlot, CardSlot fromSlot)
 {
     ToSlot = intoSlot;
     FromSlot = fromSlot;
 }
        void DiscardAllCardsInSlot(CardSlot slot, TimeSpan initialDelay)
        {
            TimeSpan delayInterval = TimeSpan.FromMilliseconds(100);
            TimeSpan delay = initialDelay;

            foreach (Card card in slot.Cards) {
                card.PlaceInSlot(discardSlot, delay);
                card.Flip();

                delay += delayInterval;
            }
        }
 void DiscardAllCardsInSlot(CardSlot slot)
 {
     DiscardAllCardsInSlot(slot, TimeSpan.Zero);
 }
        void ConvertStackToSword(CardSlot slot)
        {
            Card sword = new Card();

            CardViewModel swordCardContext = sword.DataContext as CardViewModel;

            swordCardContext.Type = CardType.Sword;
            swordCardContext.Value = slot.StackCount;

            slot.Add(sword);

            sword.Flip();
            sword.PlaceInSlot(weaponSlot, TimeSpan.FromSeconds(1));
        }