void CreateCardGameElements(List <CardIndexer> phrase) { dropoffs = new List <CardDropoff>(); for (int i = 0; i < phrase.Count; i++) { CardIndexer cardIndexer = phrase[i]; CardData card = cardIndexer.Card; CardPickup cardP = GameObject.Instantiate(CardPickup, PickupParent).GetComponent <CardPickup>(); cardP.transform.position = PickupParent.position; //Pick card based on directionality cardP.SetCard(cardIndexer, Direction); CardDropoff dropoff = GameObject.Instantiate(CardDropOff, DropoffParent).GetComponent <CardDropoff>(); dropoff.transform.position = DropoffParent.position; //From or to length string textCard = Direction == CardManager.Direction.To ? card.To : card.From; string textBlock = Direction == CardManager.Direction.To ? card.From : card.To; //Temp String formatting for capital first letter and period at end if (i == 0) { if (!string.IsNullOrEmpty(textCard)) { textCard = textCard.First().ToString().ToUpper() + textCard.Substring(1); } if (!string.IsNullOrEmpty(textBlock)) { textBlock = textBlock.First().ToString().ToUpper() + textBlock.Substring(1); } } else if (i == phrase.Count - 1) { if (!string.IsNullOrEmpty(textCard)) { textCard += "."; } if (!string.IsNullOrEmpty(textBlock)) { textBlock += "."; } } GameObject uiText = GameObject.Instantiate(TextBlock, BlockUI); uiText.GetComponentInChildren <TextMeshProUGUI>().text = textBlock; dropoff.SetCard(cardIndexer, Direction, uiText); dropoffs.Add(dropoff); } }
public void GenerateCards(int min = 1, int max = 3) { // 1-3 cards int numEntities = Random.Range(min, max + 1); GameManager gm = GameManager.singleton; Player player = gm.player; List <CardInfo> prevCards = new List <CardInfo>(); prevCards.Add(prevCard); var prevLocations = new List <Vector3>(); for (int i = 0; i < numEntities; i++) { var location = GetRandomLocation(2, prevLocations); prevLocations.Add(location); CardPickup card = Instantiate(cardPickupRef, location, Quaternion.identity).GetComponent <CardPickup>(); CardInfo newCard; int maxIterations = max * 2; int iteration = 0; do { newCard = CardDatabase.GetCardOfStatTier(player.primaryStats[0], player.primaryStats[1], gm.cardTier); iteration++; } while(prevCards.Contains(newCard) && iteration < maxIterations); prevCards.Add(newCard); prevCard = newCard; card.SetCard(newCard); GameManager.singleton.RegisterEntity(card); } }