How to i create a shuffle aray in my scripts that shuffles the arrangement of these 5 cards
var selStrings : String[] = ["Card 1", "Card 2", "Card 3", "Card 4", "Card 5"];
var deckRect : Rect = Rect (0,480,270,380);
private var cardsInHands : CardsInHands;
function Start()
{
cardsInHands = GameObject.FindGameObjectWithTag("Hands").GetComponent(CardsInHands);
}
function Update ()
{ if (selGridInt > 0) {
switch (selGridInt)
{
case 1:
break;
case 2:
break;
default:
break;
}
}
}
function OnGUI ()
{
deckRect = GUI.Window (0, deckRect, DoMyDeckWindow, "Deck");
if (GUI.Button(Rect(boxPos.x, boxPos.y, 140, 40), "Draw"))
{
DrawCard();
}
}
function DrawCard()
{
var tempCards : String[] = new String[selStrings.length-1];
for (var i : int; i < selStrings.length; i++)
{
if (i == 0)
{
print(selStrings*);*
cardsInHands.AddCards(selStrings*);*
continue;
}
tempCards[i-1] = selStrings*;*
}
selStrings = new String[tempCards.length];
for (var j : int; j < tempCards.length; j++)
{
selStrings[j] = tempCards[j];
}
}
function DoMyDeckWindow (windowID : int) {
* scrollPosition = GUI.BeginScrollView (Rect (10,20,258,358), scrollPosition, Rect (0, 0, 230, 1200));*
* selGridInt = GUI.SelectionGrid (Rect (0, 0, 235, 1200), selGridInt, selStrings, 1);*
* GUI.EndScrollView();*
}
Save as Click.js
Create a new game object tag “Hands”
var cards : Array;
var handRect : Rect = Rect (0,290,270,190);
private var cardList : String[];
private var selGridInt : int = -1;
private var scrollPosition : Vector2 = Vector2.zero;
function Start(){
cardList = new String[1];
cardList[0] = “”;
cards = new Array();
}
function AddCards (cardsToAdd : String) {
* cards.Push(cardsToAdd);*
cardList = cards.ToBuiltin(String);
print(cardList[0]);
}
function OnGUI(){
* handRect = GUI.Window (1, handRect, DoMyHandWindow, “Hand”);*
}
function DoMyHandWindow (windowID : int) {
* scrollPosition = GUI.BeginScrollView (Rect (10,20,258,140), scrollPosition, Rect (0, 0, 230, 500));*
* if (cardList != null)*
{
selGridInt = GUI.SelectionGrid (Rect (0, 50, 235, 400), selGridInt, cardList, 1);
}
* GUI.EndScrollView();*
}