I am working on a card game but the deck isn’t working The way I would hope. I put the cards in as SOs but it only keeps taking the first card I put in. Here Is the Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeckManager : MonoBehaviour
{
public List<Card> allCards = new List<Card>();
private int currentIndex = 0;
void Start()
{
Card[] cards = Resources.LoadAll<Card>("Cards");
allCards.AddRange(cards);
HandManager hand = FindObjectOfType<HandManager>();
for (int i = 0; i < 6; i++)
{
DrawCard(hand);
}
}
public void DrawCard(HandManager handManager)
{
if (allCards.Count == 0)
return;
Card nextCard = allCards[currentIndex];
handManager.AddCardToHand(nextCard);
currentIndex = (currentIndex +1) % allCards.Count;
}
}