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(); }
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)); }