Hello! I am working on a simple card game to practice my unity skills. I have an array that holds 52 images, representing the deck.
Upon the start of the game, I pull four random cards and attach them to a GUITexture on my game screen. No problems there.
However, I would like to remove these ‘used’ cards from my array but after much googling, I cannot find a good answer. Any opinions or ideas?
Here is the applicable code:
#pragma strict
//Card Array
var cards : Texture2D[];
var PlayerCards : Texture2D[];
var targetGUI1 : GUITexture;
var targetGUI2 : GUITexture;
var targetGUI3 : GUITexture;
var targetGUI4 : GUITexture;
function Start ()
{
for(var i = 0; i < 4; i++)
{
var myElement = cards[Random.Range(0, cards.Length)];
PlayerCards *= myElement;*
-
}*
-
targetGUI1.texture = PlayerCards[0];*
-
targetGUI2.texture = PlayerCards[1];*
-
targetGUI3.texture = PlayerCards[2];*
-
targetGUI4.texture = PlayerCards[3];*
}
Again, no problems filling each texture with a random card. I would like to know if it’s possible to remove the chosen cards from this Texture2D array.
Works like a charm, thank you! :)
– Kynge