So i’m trying to make a card game and i want to shuffle the deck but i have no idea how to get stuff from one array to an other so i really hope someone can help me. this is the script i want to use to shuffle the cards.
using UnityEngine;
using System.Collections;
public class DeckScript : MonoBehaviour {
//the deck 60 cards
[SerializeField]
GameObject[] decklist;
//shuffle arrays 20 cards each
[SerializeField]
GameObject[] shuffleArray1;
[SerializeField]
GameObject[] shuffleArray2;
[SerializeField]
GameObject[] shuffleArray3;
private int arraystate = 1;
// Use this for initialization
void Start () {
Shuffle();
}
// Update is called once per frame
void Update () {
}
void Shuffle()
{
int randomnumber = Random.Range(4, 20);
for (int a = 0; a < randomnumber; a++)
{
for (int i = 0; i < decklist.Length; i++)
{
switch (arraystate)
{
case 1:
//take card from decklist put in shufflearray1
Debug.Log("shuffleArray1");
arraystate += 1;
break;
case 2:
//take card from decklist put in shufflearray2
Debug.Log("shuffleArray2");
arraystate += 1;
break;
case 3:
//take card from decklist put in shufflearray3
Debug.Log("shuffleArray3");
arraystate += 1;
break;
}
if (arraystate > 3)
{
arraystate = 1;
}
}
//dump all shufflearrays in deckllist in random order
}
}
}