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; } }
public void SetCardAtIndex(int index, IngredientCardView card) { _boundsCheck(index); if (card != _cardViewList[index]) { _cardViewList[index] = _processCardView(index, card); invalidateFlag |= InvalidationFlag.STATIC_DATA; } }
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(); }
public void onCardDrop(BaseEventData e) { PointerEventData eventData = (PointerEventData)e; IngredientCardView ingredient = eventData.pointerDrag.GetComponent <IngredientCardView>(); if (ingredient == null) { Debug.LogFormat("Drag Object: {0}", eventData.pointerDrag.name); return; } Debug.LogFormat("Dropped: {0} onto Customer: {1}", ingredient.cardData.id, cardData.id); }
protected override void OnViewUpdate() { if (IsInvalid(InvalidationFlag.STATIC_DATA)) { for (int i = 0; i < _cardViewList.Length; ++i) { IngredientCardView cardView = _cardViewList[i]; if (cardView) { cardView.invalidateFlag = InvalidationFlag.STATIC_DATA; } } } }
private IngredientCardView _processCardView( int handIndex, IngredientCardView cardView) { if (cardView == null) { return(null); } _boundsCheck(handIndex); cardView.transform.SetParent(cardSlotList[handIndex]); cardView.transform.localPosition = Vector3.zero; cardView.handView = this; cardView.handSlot = cardSlotList[handIndex]; cardView.dragLayer = dragCardLayer; cardView.handIndex = handIndex; return(cardView); }
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); }
private void _handleIngredientCardBeginDrag(IngredientCardView view) { _draggedIngredient = view; }