private void _handleIngredientCardDrop(CustomerCardView customerView)
    {
        Debug.Log("PlayField Received drop of: " + customerView.cardData.titleKey);
        if (_draggedIngredient == null)
        {
            return;
        }

        CustomerCardState  customerState  = customerView.cardState;
        IngredientCardData ingredientData = _draggedIngredient.cardData as IngredientCardData;

        if (!customerState.CanAcceptCard(ingredientData))
        {
            return;
        }


        MoveRequest move = MoveRequest.Create(
            activePlayer.index,
            _draggedIngredient.handIndex,
            customerState.slotIndex);

        Assert.IsNotNull(onPlayOnCustomer);
        _draggedIngredient.isDropSuccessfull = onPlayOnCustomer(move);

        if (_draggedIngredient.isDropSuccessfull)
        {
            _droppedCustomer = customerView;
        }
    }
Example #2
0
    public bool PlayCardOnCustomer(MoveRequest move)
    {
        if (isGameOver)
        {
            Debug.LogError("Game is over!");
            return(false);
        }

        if (!activeCustomerSet.IsSlotActive(move.customerSlot))
        {
            return(false);
        }

        PlayerState        playerState    = playerGroup.GetPlayerByIndex(move.playerIndex);
        IngredientCardData ingredientData = playerState.hand.GetCard(move.handSlot);
        CustomerCardState  customerState  = activeCustomerSet.GetCustomerByIndex(move.customerSlot);

        if (playerState.cardsPlayed >= PlayerState.kMaxCardsPerTurn)
        {
            return(false);
        }
        if (!customerState.CanAcceptCard(ingredientData))
        {
            return(false);
        }

        _playCard(move, playerState, customerState, ingredientData);

        _playCardEvent();

        return(true);
    }
    private void _handleIngredientCardHover(CustomerCardView customerView)
    {
        if (_draggedIngredient == null)
        {
            return;
        }
        if (!_draggedIngredient.isDragging)
        {
            return;
        }

        CustomerCardState  customerState  = customerView.cardState;
        IngredientCardData ingredientData = _draggedIngredient.cardData as IngredientCardData;

        if (customerState.CanAcceptCard(ingredientData))
        {
            _activeHoverFX(customerView.transform.position);
        }
    }
    private void _handleIngredientCardDrop(CustomerCardView customerView)
    {
        Debug.Log("LocalPlayer: " + localPlayer.index + ", Active Player: " + activePlayer.index);

        if (localPlayer != activePlayer)
        {
            return;
        }
        if (_draggedIngredient == null)
        {
            return;
        }

        CustomerCardState  customerState  = customerView.cardState;
        IngredientCardData ingredientData = _draggedIngredient.cardData as IngredientCardData;

        if (!customerState.CanAcceptCard(ingredientData))
        {
            return;
        }

        MoveRequest move = MoveRequest.Create(
            localPlayer.index,
            _draggedIngredient.handIndex,
            customerState.slotIndex);

        Assert.IsNotNull(onPlayOnCustomer);
        _draggedIngredient.isDropSuccessfull = onPlayOnCustomer(move);

        if (_draggedIngredient.isDropSuccessfull)
        {
            _isAnimating     = true;
            _droppedCustomer = customerView;
            _moveRequests.Add(move);
        }
    }