I am trying to create a system where upon starting the game map will be selected and then generated from lets say map pool. All my maps are jaggedArrays. I tried to put jaggedArrays into ArrayList and generate from that but that did not work then I tried putting all my maps into 1 jaggedArray which look like this.
maps[0] = new string[] { null, null, null, null, null, null, null, null, null, "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "eol"}
maps[1] = new string[] { null, null, null, null, null, null, null, null, null, "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "eol"}
“eol” - represents end of line
after “eol” map information continues on another row.
(map is 24 by x and rows are limited by “eol” - x is undefined number)
Converting part of jaggedArray into separate array
// vyberMapy transates to chooseMap
public static void vyberMapy()
{
int number = Random.Range(1, 3);
int i = 0;
for (int j = 0; j < maps[number].Length; j++)
{
map1*[j] = maps[number][j].ToString();*
if (maps[number][j].ToString() == “eol”)
{
i++;
}
}
}
Conclusion
I need to figure way to randomly select one of there maps, via randomly generated number atm. of range between 1-2 and using return function to return chosen map.