samedi 6 juin 2020

How can I randomly select an array from an array of arrays

I am making a card game. 2 elements of the card are dice and hp, which each have 4 values, but there are many different combinations. I will give 2 examples, though there are many more.

So there is
int[] dice1 = { 6, 6, 0, 0}; int[] dice2 = { 8, 8, 0, 0};

And
int[] HP1 = { 3, 7, 0, 0}; int[] HP2 = { 2, 8, 0, 0};

I have already combined these into one array for each combo
int[] combo1 = dice1.Concat(HP1).ToArray(); int[] combo2 = dice1.Concat(HP2).ToArray(); int[] combo3 = dice2.Concat(HP1).ToArray(); int[] combo4 = dice2.Concat(HP2).ToArray();

Now there are different “races” and they don’t each have access to all of the combos. So I have
Array[] dragonCombos = {combo1, combo3, combo4};

As I initiate each card, I want to choose ONE combo from the array dragonCombos. I thought I could use
int thisDragonCombo[] = dragonCombos[Random.Range(0,dragonCombos.Length)];

But no such luck. How do I randomly pull an array from an array of arrays?




Aucun commentaire:

Enregistrer un commentaire