IEnumerator DrawCardsFromDeck(int drawAmount) { //Randomly Draw cards. RandomlyDrawCards(drawAmount); //Show your hand window MyHandWindow.SetActive(true); //We need to make a gameobject for each card in your hand GameObject[] gameObjects = new GameObject[Hand.hand.Count]; //We need this counter to know which card goes where int handSlot = Hand.hand.Count - 1; foreach (KeyValuePair <int, Card> card in Hand.hand) { //Assign the card handCardSlotPrefab.GetComponent <CardDisplay>().card = card.Value; handCardSlotPrefab.GetComponent <CardDisplay>().artWork.sprite = card.Value.artWork; handCardSlotPrefab.GetComponent <CardDisplay>().statsText.text = card.Value.ATK.ToString("D2") + "/" + card.Value.HP.ToString("D2"); //After drawing total up friend points MyArena.AddPlayerPoints(card.Value.type.ToString(), card.Value.points); //This helps the visuals update ArenaManager.totalCardsInDeck--; ArenaManager.totalCardsInHand++; gameObjects[handSlot] = Instantiate(handCardSlotPrefab, playerHand); gameObjects[handSlot].GetComponent <Button>().onClick.AddListener(delegate { MyHand.SelectCard(card); }); handSlot--; yield return(new WaitForSeconds(1f)); } //Close your hand window MyHandWindow.SetActive(false); //Since we could be drawing cards in other phases if (state == BattleState.DRAWPHASE) { //Next should really be AbilityPhase but we skip that for now SummonPhase(); } }