Hi, I’m really really new to C# and unity and to be honest I’m just diving right in and trying to learn as practically as possible. My lack of knowledge does mean however that I randomly encounter roadblocks such as this that are likely incredibly simply solved with just a small amount of understanding I don’t have. In other words, I’m almost certain there is an INCREDIBLY simple answer to this problem and the pulling-hair level of anger it’s been inducing in me is not worth it.
I’m working on a project with a heavy element of randomisation; to a certain extent, dialogue will be random, as will another similar feature I currently refer to as “keywords”. I want several keyword lists, grouped by theme (E.G. a list of medical keywords [“doctorate”, “mask”, “stethoscope”,“EMT”, “training”] but larger than this) and then, upon calling a routine I want one of the lists to be chosen at random, then a random handful of the keywords from that list to be chosen also. So far I’ve tried naming all the List objects that store the keywords under the same scheme, “keywordlist1”, “keywordlist2” etc, and then having a string that stores “keywordlist” + a Random.Range operation, and then using GetType().GetField().GetValue() to find the list with that name, but that broke in a very odd way. It would correctly form the name, but the GetType and so on would yield a smaller list with items from the wrong list.
Feel free to ask me for any better explanation you need, here is how the lists are currently being stored.
public List<string> keywordset1 = new List<string>() {"aaaaa","bbbbb", "ccccc","ddddd","eeeee","fffff","gggggg","hhhhh","iiiiii", "jjjjjj"};
public List<string> keywordset2 = new List<string>() {"kkkkkk","lllllll", "mmmmm","nnnnn","ooooo","ppppp","qqqqq","rrrrr","ssssss", "tttttt"};
public List<string> keywordset3 = new List<string>() {"uuuuuu","vvvvvv", "wwwwww","xxxxx","yyyyyy","zzzzzz","11111","222222","333333", "444444"};
The tl;dr question is: how do I pick one of these lists at random, then pick random words within them?
Thanks for any help I get, and please be patient - I’m a total newcomer! :]