Exemple #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);
    }
Exemple #2
0
 public void RegisterCardSlot(CardDeck newslot)
 {
     cardSlots.Add(newslot);
     newslot.onAddBehaviorButtonClicked += () =>
     {
         onCardLibraryRequest?.Invoke(newslot.GetModel().GetCardCategory(), null, newslot);
     };
     newslot.onCardClicked += (card) =>
     {
         if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
         {
             // Shortcut for copying card
             int index = newslot.GetModel().GetIndexOf(card.GetCardAssignment());
             newslot.AcceptCard(card.GetModel(), index, card.GetCardAssignment().GetProperties());
         }
         else
         {
             OpenCardDetail(card.GetCardAssignment(), card.container, FROM_CLICK_DETAIL_ANIMATION_DURATION);
         }
     };
 }
Exemple #3
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);
        }
    }