Пример #1
0
 public void OnCardsHolderBeginDrag(CardsHolder cardsHolder, int index)
 {
     if (inputEnabled && !isRunningDragHistoryCoroutine && cardsHolder.ContainsCardInIndex(index))
     {
         StartCoroutine(DragHistory(cardsHolder, index));
     }
 }
Пример #2
0
    public void OnCardsHolderDrop(CardsHolder cardsHolder, int index)
    {
        cardsHolderBelowMouseOnDrop = cardsHolder;
        indexOfSlotBelowMouseOnDrop = index;

        wasDroppedInValidSpot = true;
    }
    public void visualizeWinning()
    {
        bool con = false;

        foreach (Card card in playerImplementation.evaluatedCards.Cards)
        {
            con = false;
            foreach (Card card1 in playerImplementation.Cards)
            {
                if (card1.Equals(card))
                {
                    CardsHolder.Find(card1.CardValue + card1.suitValue).
                    transform.localScale = new Vector3(1.3f, 1.3f, 1);
                    con = true;
                    break;
                }
            }
            if (con)
            {
                continue;
            }
            foreach (Card card2 in gameManager.communityCards.cards)
            {
                if (card2.Equals(card))
                {
                    gameManager.communityCards.transform.Find(card2.CardValue + card2.suitValue).
                    transform.localScale = new Vector3(1.2f, 1.2f, 1);
                    break;
                }
            }
        }
    }
Пример #4
0
 void Start()
 {
     if (currentHolder == null)
     {
         currentHolder = transform.parent.GetComponentInParent <CardsHolder> ();
     }
 }
Пример #5
0
 private void CardDropped(CardsHolder cardsHolder)
 {
     if (_draggedCard != null)
     {
         cardsHolder.AddCard(_draggedCard);
         _draggedCard = null;
     }
 }
Пример #6
0
 public void AcceptDrag(CardsHolder cardsHolder)
 {
     Debug.Log("Accepted");
     currentHolder.CardRemove(this);
     currentHolder = cardsHolder;
     transform.SetParent(cardsHolder.gameObject.transform);
     ReturnToParent = transform.parent.GetComponent <RectTransform> ();
 }
Пример #7
0
    public void OnSlotClicked(CardsHolder cardsHolder, int index)
    {
        Card cardInSlot = cardsHolder.GetReferenceToCardAtOrGetNull(index);

        if (cardInSlot != null)
        {
            cardInSlot.OpenTip(tipPopUpOpener);
        }
    }
 public void ShowCards(bool status)
 {
     if (!interactable)
     {
         return;
     }
     for (int i = 0; i < CardsHolder.childCount; i++)
     {
         CardsHolder.GetChild(i).GetComponent <Image> ().enabled = status;
     }
 }
    public void destroyCards()
    {
        for (int i = 0; i < CardsHolder.childCount; i++)
        {
            Destroy(CardsHolder.GetChild(i).gameObject);
        }


        for (int i = 0; i < ChipsPanel.childCount; i++)
        {
            Destroy(ChipsPanel.GetChild(i).gameObject);
        }
    }
Пример #10
0
 void Start()
 {
     holder             = GetComponent <CardsHolder> ();
     holder.CardDropped = c => {
         if (holder.Closed)
         {
             return(false);
         }
         return(OnCardDropped(c));
     };
     holder.CardRemoved += OnCardRemoved;
     Init();
 }
Пример #11
0
 private void Start()
 {
     Hand = GetComponent <CardsHolder>();
 }
Пример #12
0
    private IEnumerator DragHistory(CardsHolder cardsHolder, int index)
    {
        isRunningDragHistoryCoroutine = true;
        isDragging            = true;
        wasDroppedInValidSpot = false;

        ClearSelections(new CardsHolder[] { cardsHolder });

        cardBeingDragged            = null;
        cardsHolderBelowMouseOnDrop = null;
        indexOfSlotBelowMouseOnDrop = -1;

        // Wait for the BattleFSM to recognize that the variables ware cleared
        yield return(null);

        cardsHolder.SetSelectedIndex(index);
        cardBeingDragged = cardsHolder.GetReferenceToCardAt(index);
        cardBeingDragged.cardDragAndDrop.StartDragging();

        ShowTipAboutCardBeingDragged();

        while (isDragging)
        {
            if (!PlayerInput.GetMouseButton0())
            {
                // NOTE: this is an attempt to solve a bug in which the card
                // was not ending the dragging properly, but it was hard to reproduce.
                this.isDragging = false;
                Debug.LogError("[UICardsHolderEventHandler] Mouse is not " +
                               "dragging, but this script believes it is dragging.", cardBeingDragged);
            }
            yield return(null);
        }

        if (!wasDroppedInValidSpot)
        {
            // Wait one more frame for the drop event to be called.
            yield return(null);
        }

        if (wasDroppedInValidSpot)
        {
            cardsHolderBelowMouseOnDrop.SetSelectedIndex(indexOfSlotBelowMouseOnDrop);

            // Wait for battleFSM to do it's job (like set the parent of the card).
            yield return(null);

            yield return(null);

            while (cardBeingDragged != null && ChildMaker.IsRectTransformBeingMoved(cardBeingDragged.GetRectTransform()))
            {
                yield return(null);
            }

            // A card can be null because to make the card go back instantly, a controller script should delete
            // this card, and put a clone in the place the original was.
            if (cardBeingDragged != null)
            {
                ChildMaker.AdoptAndScaleAndSmoothlyMoveToParent
                (
                    cardBeingDragged.RectTransform.parent,
                    cardBeingDragged.RectTransform,
                    delayToComeBackFromOtherSpot
                );
            }
        }

        HideCardsBeingDraggedTip();

        if (cardsHolderBelowMouseOnDrop == null)
        {
            ClearSelections(new CardsHolder[] { cardsHolder });
        }
        else
        {
            ClearSelections(new CardsHolder[] { cardsHolder, cardsHolderBelowMouseOnDrop });
        }

        if (wasDroppedInValidSpot && cardBeingDragged != null)
        {
            yield return(new WaitForSeconds(delayToComeBackFromOtherSpot));
        }

        isRunningDragHistoryCoroutine = false;
    }