I am trying to make it so that after I randomly arrange 30 numbers, I then put objects into my deck array in the positions given. I don’t understand why I’m getting the object reference error because I’m initializing my array in startGame(); The error is thrown on the output line below.
private static int[] order;
public static bool newNumber;
private static int rand;
private static Card[] deck;
private static Card [] cards;
// Use this for initialization
public static void startGame() {
Debug.Log("HELLO");
deck = new Card[30];
cards = new Card[] {new Spells("thousands", 6), new Spells("thousands", 6), new Spells("nerf", 2), new Spells("nerf", 2), new Spells("nerf", 2), new Spells("nerf", 2), new Spells("buff", 2), new Spells("buff", 2), new Spells("buff", 2), new Spells("buff", 2), new Spells("rap", 0), new Spells("rap", 0), new Spells("rap", 0), new Spells("dancer", 3), new Spells("dancer", 3), new Spells("dancer", 3), new Spells("dancer", 3), new Spells("dancer", 3), new Spells("dancer", 3), new Spells("dancer", 3), new Spells("dancer", 3), new Spells("lord", 9), new Spells("reasonable", 4), new Spells("reasonable", 4), new Spells("reasonable", 4), new Spells("reasonable", 4), new Spells("warsong", 3), new Spells("warsong", 3), new Spells("warsong", 3), new Spells("brode", 6)};
order = new int[30];
newNumber = false;
Shuffle();
}
Inside the shuffle function, the error is on the line that I’m compiling output.
deck[rand - 1] = cards*;*
-
}*
-
string output = "";*
-
for (int i = 0; i < 30; i++)*
-
{*
_ output += deck*.getName() + " ";_
_ }_
_ Debug.Log(output);*_