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