function ShuffleAndDeal()
{
var shuffledDeck:Array;
var playerOneCards: Array;
var playerTwoCards: Array;
var first:int =0;
var second:int = 1;
shuffledDeck = new Array();
playerOneCards = new Array();
playerTwoCards = new Array();
//var CardsLeft:int = Deck.length;
for(var i = 0; i < Deck.length; i++)
{
Debug.Log(Deck.length);
var randomNum = Random.Range(1,Deck.length);
shuffledDeck.Add(Deck[randomNum]);
Debug.Log("shuffled deck: " + shuffledDeck.length);
}
//var halfDeck: int = (shuffledDeck.length / 2);
for(var j = 0; j <=26 ; j++)
{
Debug.Log(first);
Debug.Log(second);
playerOneCards.Add(shuffledDeck[first]);
playerTwoCards.Add(shuffledDeck[second]);
Debug.Log(playerOneCards[first].img);
Debug.Log(playerTwoCards[second].img);
first += 2;
second += 2;
}
}
When attempting to divide the array into two separate arrays, it seems to be disregarding all elements except for the first one. There are 52 Card objects loaded into the shuffleDeck[] and I am trying to split the array so that each player can have their own deck.
Here is the console window for debugging purposes: