0
\$\begingroup\$

I am building a small Android game with Unity. Everything is going OK, but I have some things bothering me, that I see no real solution.

The problem

In my game, you build your character as you like, and you can equip him with loot that you acquire as you play the Story Mode. I am currently storing the attributes for each equipment on a database, and the game makes calls to WebServices to get these attributes.

However, this becomes a problem if the user has no internet connection, and wants to play the game. I would like the game to be playable in this case, but I can't think of a good solution.

I could store the data for the current equipment in the device, but what if the user changes the equipment? Any help is widely appreciated.

\$\endgroup\$
2
  • \$\begingroup\$ Why do you keep the loot stats online? Is the loot table actually that big? If so, have you considered a procedural loot generation approach? \$\endgroup\$ May 17 '17 at 6:01
  • \$\begingroup\$ It was more a case of "I don't really know how I would do it, so I will stick with some thing I am confortable" hahaha. But I am really open to suggestions, and I will check some procedural loot generation techniques, thank you \$\endgroup\$ May 17 '17 at 11:12
1
\$\begingroup\$

Alright, since you're looking for ways to make a loot system (and to store it) for a game, there are a few major systems that you could use.

Procedural Loot Generation

In this method, you generate loot in action. You don't keep your loot stats tied down to your loot, but instead, you make an archetype of loot and apply prefixes and suffixes or unique names if you wish.

Let's take a leather helm for example. It could just be a leather helm and it would give a random low range armor amount since it's usually called a light armor. After deciding that, you generate the item and give it to the player, then save the player's current items. This way, you don't need to keep a database of items but instead just generate them on the fly. Each suffix or prefix will need an identifying number so that you can apply updates to existing items, and items will need to draw their stats using these IDs. If you don't do it this way, then you'll need to store the stats of every item separately.

You could for example give it a prefix of "Muffled" which would give a bonus to stealth, or a better prefix of "Silent" which would give a higher stealth bonus. Both of those would be random values, depending on the quality of the prefix. This has the potential of not making any sense (Muffled Leather Helm? Wha?...), but you could restrict the attributes to loot types to make more sense.

Predefined Loots

So you want more control over your game? You want the iron sword to act exactly as you want it to, because there are reasons for wanting that. Then you could just make each and every item and put them in the game and give each of them an identifying number and when the player gets an item, they only need to have the identifying number of that item.

This way, you only ever need one of said item to exist within the code and then just use that item for everything that needs that item.

These won't need much space on the device unless you plan on having a few million items or a few million suffixes and prefixes.

Storage

If you're concerned about the size of said game then you could just use the "Split Application Binary" option and separate game's textures etc. from the main application.

If you absolutely want to have them off on a server, then I suggest holding an encrypted copy of the loot table on the server and then downloading that loot table to local storage and then decrypting and using it at runtime. You can then check the loot that the player has gathered during their offline play and compare that to the list you have on the server and just change it as necessary.

\$\endgroup\$
1
  • \$\begingroup\$ The procedural loot generation seems to be exactly what I want! I can have a lot of different items with the same sprite! Just need to be sure to store the generated item data, so when the user play online I can load it again :P \$\endgroup\$ May 17 '17 at 11:46
1
\$\begingroup\$

Just my thoughts

This depends on the scenario how your game is played/used.

Scenario 1: the web backup

This means your game is always played on android and the character remains to this one device. If the player plays the game on a second (android) device or via unity web player he gets a new character with new stats. In this case you can keep your data local and backup your data to the server in case the phone is lost or reset or game is uninstalled,.... The only case you want to load the data from the server is when the user requests the backup. In this case the player would not need a internet connection when playing (only on restore) and if an internet connection is present the data would be back uped automatically in the background. Of course here may the problem arises that the player never had an internet connection and therefore no backup on the server.

Scenario 2: the sync store

When your game is played on multiple devices with multiple clients (may not simultaneosly). This means the player plays on android while away but switches to web player or standalone game when at home on PC. In this case you have to keep them in sync all the time necessarily. Otherwise dataloss and difficult to solve syncing cases will occure. Here a constant internet connection is required.

\$\endgroup\$
1
  • \$\begingroup\$ In my case, I need to be synced, because the game has some online features (like a ranking, where you attack other players to rise up your score). The user already has to login/register to play the game, but I was thinking of some possibility to allow him/her to play it offline, disabling the online features when he does so \$\endgroup\$ May 17 '17 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.