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;
        }
    }
Ejemplo n.º 2
0
    public static void AnimateOtherPlayerMoves(List <MoveResult> moveList, GameMatchState state, ActiveCustomersView customersView, Transform parent, Action <Vector3> slamCallback, TweenCallback callback)
    {
        Assert.IsNotNull(moveList);
        //Assert.IsTrue(moveList.Count > 0);

        Sequence allPlayedCards = DOTween.Sequence();
        //MoveResult[] moveResults = new MoveResult[PlayerGroup.kMaxPlayerCount];
        int count = moveList.Count;

        for (int i = 0; i < count; ++i)
        {
            MoveRequest request = moveList[i].request;
            MoveResult  result  = moveList[i];

            CustomerCardView customerView = customersView.GetCardByIndex(request.customerSlot);

            IngredientCardData cardData = state.GetCardById(result.usedIngredient) as IngredientCardData;

            if (cardData == null)
            {
                Debug.LogError("Card data is null! cant animate other player card");
                continue;
            }

            IngredientCardView ingredientView = Singleton.instance.cardResourceBank.CreateCardView(
                cardData,
                parent) as IngredientCardView;

            ingredientView.transform.position = parent.transform.position;

            Vector3 delta     = (Camera.main.transform.position - customerView.transform.position).normalized;
            Vector3 targetPos = customerView.transform.position + delta;
            Tween   moveTo    = ingredientView.transform.DOMove(targetPos, 0.75f);
            moveTo.SetEase(Ease.OutQuad);

            ViewFactory vf = Singleton.instance.gui.viewFactory;

            Tween zoomSlam = ZoomSlamTween(ingredientView, customerView, false, () =>
            {
                vf.RemoveView(ingredientView);
                if (slamCallback != null)
                {
                    slamCallback(ingredientView.transform.position);
                }
            }, null);

            Sequence cardTween = DOTween.Sequence();
            cardTween.Append(moveTo);
            cardTween.Insert(moveTo.Duration(false) * 0.75f, zoomSlam);

            allPlayedCards.Insert(i * (cardTween.Duration() * 0.95f), cardTween);
        }
        allPlayedCards.OnComplete(callback);
        allPlayedCards.Play();
    }
Ejemplo n.º 3
0
    public void SetCardByIndex(int index, CustomerCardView cardView)
    {
        _boundsCheck(index);
        cardView.gameObject.SetActive(true);

        if (_cardViewList[index] != cardView)
        {
            _cardViewList[index] = cardView;
            invalidateFlag      |= InvalidationFlag.STATIC_DATA;
        }
    }
    private void _handleIngredientCardHoverEnd(CustomerCardView customerView)
    {
        if (_draggedIngredient == null)
        {
            return;
        }
        if (!_draggedIngredient.isDragging)
        {
            return;
        }

        _activeHoverFX(customerView.transform.position);
    }
Ejemplo n.º 5
0
 protected override void OnViewUpdate()
 {
     base.OnViewUpdate();
     if (IsInvalid(InvalidationFlag.ALL))
     {
         for (int i = 0; i < ActiveCustomerSet.kMaxActiveCustomers; ++i)
         {
             CustomerCardView cardView = _cardViewList[i];
             if (cardView != null)
             {
                 cardView.invalidateFlag = InvalidationFlag.ALL;
             }
         }
     }
 }
Ejemplo n.º 6
0
    static public void SetupCustomerView(
        ActiveCustomersView customersView,
        int customerIndex,
        CustomerCardState cardState,
        Action <CustomerCardView> onCardDrop,
        Action <CustomerCardView> onPointerEnter,
        Action onPointerExit)
    {
        if (cardState == null)
        {
            Debug.LogWarning("Card State is null!");
            customersView.RemoveCardByIndex(customerIndex); // TODO: Do this On card slam instead of after the fact
            return;
        }

        CustomerCardView view = customersView.GetCardByIndex(customerIndex);

        if (view == null)
        {
            view = (CustomerCardView)Singleton.instance.cardResourceBank.CreateCardView(
                cardState.cardData,
                customersView._activeSlotList[customerIndex]);
        }

        view.cardState = cardState;

        view.eventTrigger.triggers.Clear();
        EventTrigger.Entry OnDrop = new EventTrigger.Entry();
        OnDrop.eventID = EventTriggerType.Drop;
        OnDrop.callback.AddListener((e) => onCardDrop(view));
        view.eventTrigger.triggers.Add(OnDrop);

        EventTrigger.Entry OnHoverBegin = new EventTrigger.Entry();
        OnHoverBegin.eventID = EventTriggerType.PointerEnter;
        OnHoverBegin.callback.AddListener((e) => onPointerEnter(view));
        view.eventTrigger.triggers.Add(OnHoverBegin);

        EventTrigger.Entry OnHoverEnd = new EventTrigger.Entry();
        OnHoverEnd.eventID = EventTriggerType.PointerExit;
        OnHoverEnd.callback.AddListener((e) => onPointerExit());
        view.eventTrigger.triggers.Add(OnHoverEnd);

        customersView.SetCardByIndex(customerIndex, view);
    }
    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);
        }
    }
Ejemplo n.º 9
0
 private void _moveCardToSlot(int index, CustomerCardView cardView) // TODO: Tween or do something cool!
 {
     cardView.transform.position = _activeSlotList[index].position;
 }
Ejemplo n.º 10
0
 private CustomerCardView _processCustomerCard(int index, CustomerCardView view)
 {
     _moveCardToSlot(index, view);
     return(view);
 }