private void _onCardDropFinished()
    {
        int handIndex     = _draggedIngredient.handIndex;
        int customerIndex = _droppedCustomer.cardState.slotIndex;

        _draggedIngredient = null;

        _playerHandView.RemoveCardByIndex(handIndex);

        Assert.IsNotNull(onResolveScore);
        bool customerFinished = onResolveScore(customerIndex);

        if (customerFinished)
        {
            _playfieldView.SetPlayerScore(activePlayer.index, activePlayer.score);
            CustomerCardState newState = _matchState.activeCustomerSet.GetCustomerByIndex(customerIndex);
            _setupCustomerView(customerIndex, newState);
        }

        _playerHandView.blockCardDrag = false;
        _isAnimating = false;

        if (_timerEndedTurn)
        {
            _endPlayerTurn(true);
            _timerEndedTurn = false;
        }
    }
Exemplo n.º 2
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.º 3
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;
        }
    }
Exemplo n.º 4
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);
    }