protected override CardView RemoveDelayedTool(Card card, bool isCopy) { SmallDelayedToolView dtv = null; foreach (var tmpDtv in delayedToolsDock.Children) { dtv = tmpDtv as SmallDelayedToolView; Trace.Assert(dtv != null); CardViewModel model = dtv.DataContext as CardViewModel; Trace.Assert(model != null); if (model.Card == card) { break; } dtv = null; } Trace.Assert(dtv != null); Point dest = dtv.TranslatePoint(new Point(0, 0), ParentGameView.GlobalCanvas); if (!isCopy) { delayedToolsDock.Children.Remove(dtv); } CardView result = CardView.CreateCard(card); ParentGameView.GlobalCanvas.Children.Add(result); result.Opacity = 0; result.SetCurrentPosition(dest); return(result); }
protected override CardView RemoveRoleCard(Card card) { CardView result = CardView.CreateCard(card); ParentGameView.GlobalCanvas.Children.Add(result); result.Opacity = 0; result.SetCurrentPosition(ComputeCardCenterPos(result, cbRoleBox)); return(result); }
protected override CardView RemoveEquipment(Card card, bool isCopy) { Trace.Assert(card.Id >= 0, "Cannot remove unknown card from equip area."); Equipment equip = GameEngine.CardSet[card.Id].Type as Equipment; if (equip == null) { throw new ArgumentException("Cannot add non-equip to equip area."); } 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."); } if (targetArea.Child == null) { throw new ArgumentException("No equip is found."); } SmallEquipView equipLabel = targetArea.Child as SmallEquipView; if (!isCopy) { targetArea.Child = null; } CardView result = CardView.CreateCard(card); ParentGameView.GlobalCanvas.Children.Add(result); result.Opacity = 0; result.SetCurrentPosition(ComputeCardCenterPos(result, targetArea)); return(result); }
protected override CardView RemoveEquipment(Card card, bool isCopy) { Trace.Assert(card.Id >= 0, "Cannot remove unknown card from equip area."); Equipment equip = GameEngine.CardSet[card.Id].Type as Equipment; if (equip == null) { throw new ArgumentException("Cannot add non-equip to equip area."); } Grid 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."); } if (targetArea.Children.Count == 0) { throw new ArgumentException("No equip is found."); } ToggleButton button = targetArea.Children[0] as ToggleButton; if (!isCopy) { targetArea.Children.Clear(); } if (IsEquipmentDockEmpty) { equipmentArea.Visibility = Visibility.Collapsed; handCardArea.RearrangeCards(); } CardView result = CardView.CreateCard(card); ParentGameView.GlobalCanvas.Children.Add(result); result.Opacity = 0; Point dest = targetArea.TranslatePoint(new Point(targetArea.Width / 2, targetArea.Height / 2), ParentGameView.GlobalCanvas); dest.Offset(-result.Width / 2, -result.Height / 2); result.SetCurrentPosition(dest); return(result); }