Example #1
0
    public void AcceptClickedLibraryCard(Card card, CardContainer targetContainer, CardDeck targetSlot)
    {
        Card newCard = null;

        if (targetContainer != null)
        {
            newCard = targetContainer.ReplaceCard(card.GetModel());
        }
        else
        {
            newCard = targetSlot.AcceptCard(card.GetModel());

            string uri = newCard.GetCardAssignment().GetCard().GetUri();
            if (BehaviorSystem.IsBuiltinBehaviorUri(uri))
            {
            }
        }
        OnNewCardAdded(newCard);
    }
Example #2
0
    public void MaybeAcceptDraggedCard(Card card)
    {
        pointerState = PointerState.MouseOver;

        bool isFromLibrary = card.GetCardAssignment() == null;
        Card newcard       = null;

        foreach (CardDeck slot in cardSlots)
        {
            slot.ToggleReplaceIndicator(false);
            foreach (CardContainer container in slot.containers)
            {
                if (container != null)
                {
                    container.ToggleReplaceIndicator(false);
                }
            }
        }

        bool placed = false;

        if (IsCardOverTrash(card))
        {
            UnassignCard(card.GetCardAssignment());
        }

        else if (mouseOverContainer != null)
        {
            if (mouseOverContainer.deck != card.GetCurrentSlot())
            {
                CardContainer targetContainer = mouseOverContainer;
                card.OnCardPlaced?.Invoke();
                if (isFromLibrary)
                {
                    newcard = targetContainer.ReplaceCard(card.GetModel());
                }
                else
                {
                    newcard = targetContainer.ReplaceCard(card.GetCardAssignment());
                }
                placed = true;
            }
        }
        else
        {
            CardDeck slot = GetMouseoverSlot(card);
            if (slot != null)
            {
                if (slot != card.GetCurrentSlot())
                {
                    card.OnCardPlaced?.Invoke();
                    if (isFromLibrary)
                    {
                        newcard = slot.AcceptCard(card.GetModel());
                    }
                    else
                    {
                        newcard = slot.AcceptAssignedCard(card.GetCardAssignment());
                    }
                    placed = true;
                }
            }
        }

        if (mouseOverSlot != null)
        {
            mouseOverSlot.EndFocus();
            mouseOverSlot = null;
        }
        if (mouseOverContainer != null)
        {
            mouseOverContainer.EndFocus();
            mouseOverContainer = null;
        }

        if (newcard != null)
        {
            focusCard = newcard;
            focusCard.EnterFocus();
        }

        if (placed && isFromLibrary)
        {
            OnNewCardAdded(newcard);
        }
    }