I am making a game where I will have a large list (100-200) of monsters with their associated stats (name, health, attack, defense, type, etc). I set it up to have a monster class that contains all the stats as variables and will do the necessary methods such as attacking or gaining xp. When the player is playing the game, they will have their own monster which will have stats that change as the level and I will need to save this information. All the other monsters will be stored in a list where I will ask for one specific monster only when it is time to battle.
With my limited knowledge of Java and the Android SDK, I have come up with a possible solution but it seems like more work than is needed. I plan on having separate resource value xml files for each stat, so one for the monster name, one for its health, etc with the values being stored in an a开发者_开发知识库rray. In my game, I will create an array for each stat then retrieve the value based upon an index number generated corresponding to a monster.
This seems like more work than needed because I am creating and importing all the arrays from the file instead of just the values corresponding to the one monster I want. Is there a way that would be less resource intensive on my game and easier to deal with? Also what would be the best way to save the particular monster that player is using and leveling up that I can retrieve the next time the start the app?
Here's a list with data storage options on Android: http://developer.android.com/guide/topics/data/data-storage.html
If you plan to add more levels to your game (100+ monsters is already much) my best recommendation is an SQLite Database: http://developer.android.com/guide/topics/data/data-storage.html#db
You could always try using enums for the monster information. not sure if it's more efficient or not. as for the useris monster information you can just store it in sharedpreferences.
精彩评论