Exemplo n.º 1
0
    public static void SetupCardView(
        PlayerHandView handView,
        int handSlot,
        CardData cardData,
        Action <CardView> onBeginDrag,
        Action onEndDrag)
    {
        if (cardData == null)
        {
            Debug.LogWarning("Card Data is null!");
            handView.RemoveCardByIndex(handSlot); // TODO: Do this On card slam instead of after the fact
            return;
        }

        CardView view = handView.GetCardAtIndex(handSlot);

        if (view == null)
        {
            view = Singleton.instance.cardResourceBank.CreateCardView(
                cardData,
                handView.cardSlotList[handSlot]);
        }

        view.cardData = cardData;

        handView.SetCardAtIndex(handSlot, view);
    }
Exemplo n.º 2
0
    public static void SetupIngredientView(
        PlayerHandView handView,
        int handSlot,
        IngredientCardData cardData,
        Action <IngredientCardView> onBeginDrag,
        Action onEndDrag)
    {
        if (cardData == null)
        {
            Debug.LogWarning("Card Data is null!");
            handView.RemoveCardByIndex(handSlot); // TODO: Do this On card slam instead of after the fact
            return;
        }

        IngredientCardView view = handView.GetCardAtIndex(handSlot);

        if (view == null)
        {
            view = Singleton.instance.cardResourceBank.CreateCardView(
                cardData,
                handView.cardSlotList[handSlot]) as IngredientCardView;
        }

        view.cardData = cardData;

        view.eventTrigger.triggers.Clear();
        EventTrigger.Entry OnBeginDrag = new EventTrigger.Entry();
        OnBeginDrag.eventID = EventTriggerType.BeginDrag;
        OnBeginDrag.callback.AddListener((e) => onBeginDrag(view));
        view.eventTrigger.triggers.Add(OnBeginDrag);

        EventTrigger.Entry OnEndDrag = new EventTrigger.Entry();
        OnEndDrag.eventID = EventTriggerType.EndDrag;
        OnEndDrag.callback.AddListener((e) => onEndDrag());
        view.eventTrigger.triggers.Add(OnEndDrag);

        handView.SetCardAtIndex(handSlot, view);
    }