Esempio n. 1
0
        void Update()
        {
            selectedDeck = GetSelectedInteractable();
            if (Input.GetMouseButtonDown(0) && selectedDeck != null)
            {
                if (storeCard.NumberOfCards() == 0 && selectedDeck.lockPickup == false)
                {
                    try
                    {
                        storeCard.AddCardToTop(selectedDeck.GetCard(cam.ScreenToWorldPoint(Input.mousePosition)));

                        Card selectedCard = new Card(storeCard.GetCardSuit(0), storeCard.GetCardRank(0));
                        onCardPickup?.Invoke(selectedDeck, selectedCard);
                    }
                    catch { }

                    prevInteractable = selectedDeck;
                }

                else if (storeCard.NumberOfCards() != 0 && selectedDeck.lockPlace == false)
                {
                    selectedDeck.GiveCard(storeCard.TakeTopCard());
                    onCardPlace?.Invoke(selectedDeck, prevInteractable);

                    prevInteractable = selectedDeck;
                }
            }


            if (storeCard.NumberOfCards() > 0)
            {
                render.renderedCard = new Card(storeCard.GetCardSuit(0), storeCard.GetCardRank(0), storeCard.GetCardBack(0));
            }
            else
            {
                render.renderedCard = null;
            }
        }