How do I take the contents of one list and copy that data into another list? I have a class which handles deck related things, such as building decks, loading files, etc. Now when I use Debug.Log here to list the contents of the lists, it works fine.
What I am having trouble with is taking the contents from the deck list, and placing it into a playerDeck/enemyDeck list. I don’t know if more of my code is needed to see what is happening, if it is I can provide it. Also maybe it is important, maybe not, but the list is a list of gameObjects.
deck.cs
public void AddToDeck(string[] myDeck)
{
deck.Clear();
foreach(string line in myDeck)
{
if(line == "0")
{
WarriorCard battleChariot = new WarriorCard("Battle Chariot", 1, 12, 1);
deck.Add(battleChariot);
Debug.Log(battleChariot.Name);
Debug.Log(battleChariot.HP);
Debug.Log(battleChariot.DMG);
}
}
mainGame.cs
void BuildDeck(string file)
{
if(m_state == GameState.PlayerTurn)
{
deckInstance.Load(file);
deckInstance.Shuffle();
playerDeck = deckInstance.deck;
Debug.Log(playerDeck.battleChariot.Name);
/*deck is the list variable used within the deck class and I have a new instance within this class*/
}
else if(m_state == GameState.AITurn)
{
deckInstance.Load(file);
deckInstance.Shuffle();
aiDeck = deckInstance.deck;
}
}