private void CreateCardForDeck(PlayableCard playableCard) { var newCard = Instantiate(cardPrefab); newCard.GetComponent <Card>().SetCardDetails(playableCard); newCard.gameObject.name = playableCard.ToString(); newCard.transform.SetParent(gameDeck.GetComponent <RectTransform>(), false); // non mi serve sia figlia delle rect transform degli slot newCard.transform.SetAsFirstSibling(); newCard.GetComponent <RectTransform>().position = spawnPoint.position; gameDeck.AddCardToStock(newCard); }
public IEnumerator CreateCardForPile(Pile pile, PlayableCard cardToAdd, bool lastCardOfPile) { var newCard = Instantiate(cardPrefab); yield return(new WaitForSeconds(.1f)); newCard.GetComponent <Card>().SetCardDetails(cardToAdd); newCard.gameObject.name = cardToAdd.ToString(); newCard.transform.SetParent(pile.AppendSlot.GetComponent <RectTransform>(), false); newCard.GetComponent <RectTransform>().position = spawnPoint.position; Coroutine travelCoroutine = StartCoroutine(newCard.GetComponent <Card>().TravelTo(pile.SpotPosition)); if (lastCardOfPile) { //yield return travelCoroutine; StartCoroutine(newCard.GetComponent <Card>().Flip()); } pile.AddCardToPile(newCard, lastCardOfPile); }