Beispiel #1
0
        protected override void AddRoleCard(CardView card, bool isFaked)
        {
            if (isFaked)
            {
                card.Disappear(0d, true);
                return;
            }

            card.Position = ComputeCardCenterPos(card, cbRoleBox);

            ScaleTransform scale          = new ScaleTransform();
            var            transformGroup = new TransformGroup();

            transformGroup.Children.Add(scale);
            card.RenderTransform = transformGroup;

            card.RenderTransformOrigin = new Point(0.5, 0.5);
            DoubleAnimation scaleXAnim = new DoubleAnimation(0.2, new Duration(TimeSpan.FromSeconds(0.5d)));
            DoubleAnimation scaleYAnim = new DoubleAnimation(0.2, new Duration(TimeSpan.FromSeconds(0.5d)));

            Storyboard.SetTarget(scaleXAnim, card);
            Storyboard.SetTarget(scaleYAnim, card);
            Storyboard.SetTargetProperty(scaleXAnim, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
            Storyboard.SetTargetProperty(scaleYAnim, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
            Storyboard storyboard = new Storyboard();

            storyboard.Children.Add(scaleXAnim);
            storyboard.Children.Add(scaleYAnim);
            card.AddRebaseAnimation(storyboard, 0.5d);
            storyboard.AccelerationRatio = 0.4d;
            storyboard.Begin();
            card.Disappear(0.5d, true);
        }
Beispiel #2
0
        protected override void AddDelayedTool(CardView card, bool isFaked)
        {
            LargeDelayedToolView dtv = new LargeDelayedToolView()
            {
                Width = 30, Height = 30
            };

            dtv.DataContext = card.CardModel;
            dtv.Opacity     = 0;
            dtv.Margin      = new Thickness(50d, 0, 0, 0);
            delayedToolsDock.Children.Add(dtv);
            dtv.Opacity = 1d;
            dtv.Margin  = new Thickness(0d, 0, 0, 0);

            if (isFaked)
            {
                card.Disappear(0d, true);
            }
            else
            {
                Point dest = delayedToolsDock.TranslatePoint(new Point(delayedToolsDock.ActualWidth + 15, delayedToolsDock.ActualHeight / 2),
                                                             ParentGameView.GlobalCanvas);
                dest.Offset(-card.Width / 2, -card.Height / 2);
                card.Position = dest;
                card.Disappear(0.5d, true);
                card.Rebase();
            }

            Storyboard         storyBoard = new Storyboard();
            ThicknessAnimation animation1 = new ThicknessAnimation();
            DoubleAnimation    animation2 = new DoubleAnimation();

            animation1.To       = new Thickness(0d, 0d, 0d, 0d);
            animation2.To       = 1.0d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, dtv);
            Storyboard.SetTarget(animation2, dtv);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(LargeDelayedToolView.MarginProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(LargeDelayedToolView.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }
Beispiel #3
0
        protected override void AddRoleCard(CardView card, bool isFaked)
        {
            if (isFaked)
            {
                card.Disappear(0d, true);
                return;
            }

            card.Position = ComputeCardCenterPos(card, cbRoleBox);

            ScaleTransform scale = new ScaleTransform();
            var transformGroup = new TransformGroup();
            transformGroup.Children.Add(scale);
            card.RenderTransform = transformGroup;

            card.RenderTransformOrigin = new Point(0.5, 0.5);
            DoubleAnimation scaleXAnim = new DoubleAnimation(0.2, new Duration(TimeSpan.FromSeconds(0.5d)));
            DoubleAnimation scaleYAnim = new DoubleAnimation(0.2, new Duration(TimeSpan.FromSeconds(0.5d)));
            Storyboard.SetTarget(scaleXAnim, card);
            Storyboard.SetTarget(scaleYAnim, card);
            Storyboard.SetTargetProperty(scaleXAnim, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
            Storyboard.SetTargetProperty(scaleYAnim, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(scaleXAnim);
            storyboard.Children.Add(scaleYAnim);
            card.AddRebaseAnimation(storyboard, 0.5d);
            storyboard.AccelerationRatio = 0.4d;
            storyboard.Begin();
            card.Disappear(0.5d, true);
        }
Beispiel #4
0
        protected override void AddEquipment(CardView card, bool isFaked)
        {
            Equipment equip = card.Card.Type as Equipment;

            if (equip == null)
            {
                throw new ArgumentException("Cannot add non-equip to equip area.");
            }

            SmallEquipView equipLabel = new SmallEquipView();
            equipLabel.DataContext = card.CardModel;

            Canvas targetArea = null;
            switch (equip.Category)
            {
                case CardCategory.Weapon:
                    targetArea = weaponArea;
                    break;
                case CardCategory.Armor:
                    targetArea = armorArea;
                    break;
                case CardCategory.DefensiveHorse:
                    targetArea = horse1Area;
                    break;
                case CardCategory.OffensiveHorse:
                    targetArea = horse2Area;
                    break;
                default:
                    throw new ArgumentException("Cannot install non-equips to equip area.");
            }
            equipLabel.Opacity = 0;

            if (targetArea.Children.Count != 0)
            {
                throw new ArgumentException("Duplicate equip not allowed.");
            }
            targetArea.Children.Clear();
            targetArea.Children.Add(equipLabel);

            if (isFaked)
            {
                card.Disappear(0d, true);
            }
            else
            {
                card.Position = ComputeCardCenterPos(card, targetArea);
                card.Disappear(0.3d, true);
                card.Rebase();
            }

            Storyboard storyBoard = new Storyboard();
            DoubleAnimation animation1 = new DoubleAnimation();
            DoubleAnimation animation2 = new DoubleAnimation();
            animation1.From = -50d;
            animation1.To = 0d;
            animation2.To = 1d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, equipLabel);
            Storyboard.SetTarget(animation2, equipLabel);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(Canvas.TopProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(SmallEquipView.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }
Beispiel #5
0
        protected override void AddDelayedTool(CardView card, bool isFaked)
        {
            SmallDelayedToolView dtv = new SmallDelayedToolView() { Width = 23, Height = 24 };
            dtv.DataContext = card.CardModel;
            dtv.Opacity = 0;
            dtv.Margin = new Thickness(0, 0, 50d, 0);
            delayedToolsDock.Children.Add(dtv);

            if (isFaked)
            {
                card.Disappear(0d, true);
            }
            else
            {
                Point dest = delayedToolsDock.TranslatePoint(new Point(-11.5, delayedToolsDock.ActualHeight / 2),
                                                                       ParentGameView.GlobalCanvas);
                dest.Offset(-card.Width / 2, -card.Height / 2);
                card.Position = dest;
                card.Disappear(0.5d, true);
                card.Rebase();
            }

            Storyboard storyBoard = new Storyboard();
            ThicknessAnimation animation1 = new ThicknessAnimation();
            DoubleAnimation animation2 = new DoubleAnimation();
            animation1.To = new Thickness(0d, 0d, 0d, 0d);
            animation2.To = 1.0d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, dtv);
            Storyboard.SetTarget(animation2, dtv);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(SmallDelayedToolView.MarginProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(SmallDelayedToolView.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }
Beispiel #6
0
        protected override void AddEquipment(CardView card, bool isFaked)
        {
            Equipment equip = card.Card.Type as Equipment;

            if (equip == null)
            {
                throw new ArgumentException("Cannot add non-equip to equip area.");
            }

            ToggleButton button = new ToggleButton();
            button.Style = Resources["BigEquipToggleButton"] as Style;
            button.HorizontalAlignment = HorizontalAlignment.Left;
            button.VerticalAlignment = VerticalAlignment.Top;

            Grid targetArea = null;
            switch (equip.Category)
            {
                case CardCategory.Weapon:
                    button.DataContext = PlayerModel.WeaponCommand;
                    targetArea = weaponArea;
                    break;
                case CardCategory.Armor:
                    button.DataContext = PlayerModel.ArmorCommand;
                    targetArea = armorArea;
                    break;
                case CardCategory.DefensiveHorse:
                    button.DataContext = PlayerModel.DefensiveHorseCommand;
                    targetArea = horse1Area;
                    break;
                case CardCategory.OffensiveHorse:
                    button.DataContext = PlayerModel.OffensiveHorseCommand;
                    targetArea = horse2Area;
                    break;
                default:
                    throw new ArgumentException("Cannot install non-equips to equip area.");
            }

            button.Width = targetArea.Width;
            button.Height = targetArea.Height;
            button.Opacity = 0;

            if (targetArea.Children.Count != 0)
            {
                throw new ArgumentException("Duplicate equip not allowed.");
            }
            targetArea.Children.Clear();
            targetArea.Children.Add(button);

            if (isFaked)
            {
                card.Disappear(0d);
            }
            else
            {
                Point dest = targetArea.TranslatePoint(new Point(targetArea.Width / 2, targetArea.Height / 2),
                                                       ParentGameView.GlobalCanvas);
                dest.Offset(-card.Width / 2, -card.Height / 2);
                card.Position = dest;
                card.Disappear(0.5d);
                card.Rebase(0.5d);
            }

            Storyboard storyBoard = new Storyboard();
            ThicknessAnimation animation1 = new ThicknessAnimation();
            DoubleAnimation animation2 = new DoubleAnimation();
            animation1.From = new Thickness(-100d, 0d, 0d, 0d);
            animation1.To = new Thickness(0d, 0d, 0d, 0d);
            animation2.To = 1.0d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, button);
            Storyboard.SetTarget(animation2, button);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(ToggleButton.MarginProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(ToggleButton.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }
Beispiel #7
0
 private void _MakeDisappear(CardView card)
 {
     card.SetValue(Canvas.ZIndexProperty, (int)card.GetValue(Canvas.ZIndexProperty) - 100);
     Cards.Remove(card);
     card.Disappear(0.5d, true);
 }
Beispiel #8
0
        protected override void AddEquipment(CardView card, bool isFaked)
        {
            Equipment equip = card.Card.Type as Equipment;

            if (equip == null)
            {
                throw new ArgumentException("Cannot add non-equip to equip area.");
            }

            SmallEquipView equipLabel = new SmallEquipView();

            equipLabel.DataContext = card.CardModel;

            Border targetArea = null;

            switch (equip.Category)
            {
            case CardCategory.Weapon:
                targetArea = weaponArea;
                break;

            case CardCategory.Armor:
                targetArea = armorArea;
                break;

            case CardCategory.DefensiveHorse:
                targetArea = horse1Area;
                break;

            case CardCategory.OffensiveHorse:
                targetArea = horse2Area;
                break;

            default:
                throw new ArgumentException("Cannot install non-equips to equip area.");
            }
            equipLabel.Opacity = 0;

            if (targetArea.Child != null)
            {
                throw new ArgumentException("Duplicate equip not allowed.");
            }
            targetArea.Child = equipLabel;

            if (isFaked)
            {
                card.Disappear(0d, true);
            }
            else
            {
                card.Position = ComputeCardCenterPos(card, targetArea);
                card.Disappear(0.3d, true);
                card.Rebase();
            }

            Storyboard      storyBoard = new Storyboard();
            DoubleAnimation animation1 = new DoubleAnimation();
            DoubleAnimation animation2 = new DoubleAnimation();

            animation1.From     = -50d;
            animation1.To       = 0d;
            animation2.To       = 1d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, equipLabel);
            Storyboard.SetTarget(animation2, equipLabel);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(Canvas.TopProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(SmallEquipView.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }
Beispiel #9
0
 private void _MakeDisappear(CardView card)
 {
     card.Disappear(0.5d);
     Cards.Remove(card);
 }
Beispiel #10
0
        protected override void AddEquipment(CardView card, bool isFaked)
        {
            Equipment equip = card.Card.Type as Equipment;

            if (equip == null)
            {
                throw new ArgumentException("Cannot add non-equip to equip area.");
            }

            ToggleButton button = new ToggleButton();

            button.Style = Resources["BigEquipToggleButton"] as Style;
            button.HorizontalAlignment = HorizontalAlignment.Left;
            button.VerticalAlignment   = VerticalAlignment.Top;

            Grid targetArea = null;

            switch (equip.Category)
            {
            case CardCategory.Weapon:
                button.DataContext = PlayerModel.WeaponCommand;
                targetArea         = weaponArea;
                break;

            case CardCategory.Armor:
                button.DataContext = PlayerModel.ArmorCommand;
                targetArea         = armorArea;
                break;

            case CardCategory.DefensiveHorse:
                button.DataContext = PlayerModel.DefensiveHorseCommand;
                targetArea         = horse1Area;
                break;

            case CardCategory.OffensiveHorse:
                button.DataContext = PlayerModel.OffensiveHorseCommand;
                targetArea         = horse2Area;
                break;

            default:
                throw new ArgumentException("Cannot install non-equips to equip area.");
            }

            button.Width   = targetArea.Width;
            button.Height  = targetArea.Height;
            button.Opacity = 0;

            if (IsEquipmentDockEmpty)
            {
                equipmentArea.Visibility = Visibility.Visible;
                this.UpdateLayout();
                handCardArea.RearrangeCards();
            }

            if (targetArea.Children.Count != 0)
            {
                throw new ArgumentException("Duplicate equip not allowed.");
            }
            targetArea.Children.Clear();
            targetArea.Children.Add(button);

            if (isFaked)
            {
                card.Disappear(0d, true);
            }
            else
            {
                Point dest = targetArea.TranslatePoint(new Point(targetArea.Width / 2, targetArea.Height / 2),
                                                       ParentGameView.GlobalCanvas);
                dest.Offset(-card.Width / 2, -card.Height / 2);
                card.Position = dest;
                card.Disappear(0.5d, true);
                card.Rebase();
            }

            Storyboard         storyBoard = new Storyboard();
            ThicknessAnimation animation1 = new ThicknessAnimation();
            DoubleAnimation    animation2 = new DoubleAnimation();

            animation1.From     = new Thickness(-100d, 0d, 0d, 0d);
            animation1.To       = new Thickness(0d, 0d, 0d, 0d);
            animation2.To       = 1.0d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, button);
            Storyboard.SetTarget(animation2, button);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(ToggleButton.MarginProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(ToggleButton.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }
Beispiel #11
0
 private void _MakeDisappear(CardView card)
 {
     card.Disappear(0.5d);
     card.SetValue(Canvas.ZIndexProperty, (int)card.GetValue(Canvas.ZIndexProperty) - 100);
     Cards.Remove(card);
 }