Ejemplo 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);
    }
Ejemplo n.º 2
0
    private void _setupPlayerHand(int playerIndex)
    {
        _playerHandView.playerIndex = playerIndex;
        PlayerState player = _matchState.playerGroup.GetPlayerByIndex(playerIndex);

        for (int i = 0; i < PlayerHand.kFirstHandSize; ++i)
        {
            _playerHandView.RemoveCardByIndex(i);
            CardData cardData = player.hand.GetCard(i);
            if (cardData != null)
            {
                CardView view = _gameplayResources.CreateCardView(cardData, _playerHandView.transform);
                _playerHandView.SetCardAtIndex(i, view);
                view.Validate();
            }
        }

        if (_boardView)
        {
            _boardView.viewIndex = playerIndex;
        }
    }
Ejemplo n.º 3
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);
    }