I’m building a trivia game for the Android platform. There’s going to be a number of categories, each containing 50-100 questions (along with answer data etc). In the game, the player gets a randomized selection of 3 categories and picks one, after which a question of the relevant category is loaded and presented. This process loops until the level target of correct answers is met.
My intent was to load the questions from an XML file into a list (they are stored in separate XML files, labeled by category), so I could easily remove a question from that list after it has been used and the player wouldn’t get any repeated questions should they choose the same category again. In order to save memory, I also intended to only load the relevant questions into a new list after a category has been selected instead of loading them all in at once during Start (since I may not even need some of the categories). However, I’ve heard many different things about lists being slow once they have a fair amount of objects in them, and I’m unsure if my loading approach is the best idea either as I don’t know what the performance impact of loading data from an XML is. I know I could also avoid lists and use arrays instead, then store chosen question ID’s and loop over them, but that solution seemed rather clunky to me as theoretically it’s possible for the randomizer to keep getting the same chosen ID over and over.
Overall there’s a lot of choices and I’m quite clueless when it comes to performance related questions, so I figured I’d try to get some opinions from more experienced people.
Considering I’m dealing with a mobile platform, what would be the most performance-friendly way to achieve this?
Arrays or Lists?
Load relevant data during gameplay when it’s needed, or all at once during Start?
I hope I was clear enough. Thank you for your time!