Managing Missions through database?

How would one go about managing missions for an online game through a database?
The reason I want to do it that way is so I can continuously update the available missions without having to push out updates every week.

I know there has to be some way to do this. I just can’t think of a way client side to update the actual functionality.
It’s a hacking game. So for example.

“Mission Name: ZetaFORGE: CDC Data.”
“Description”
“Payment” (what you get if you win).
“X”
“Y” (X & Y) would be the the location (float) of the position on the map inside Unity.
“Rank Required”
“Time To Complete”

Alright, that all sounds perfectly fine (in my opinion).
But where my question gets complicated on my end. Is how could one make the actual game know (Hey this is a file deletion hack, not an information system like the Social Security Administration). (So to show the proper UI’s, based on the mission type.). Then to actually (sense this is file deletion) - show the proper file based on the name of the file that needs to be deleted.

Sorry if this sounds overly complicated, just don’t know how else to explain it.
So pretty much longer story short.

1- Unity Reads the database when you login to game.
2- Unity reads the X & Y Coordinates and mission names then places them on the world map.
3- Tap the mission and load it.
4- Upon loading - load the correct (UI, Mission Info, any images if needed, etc).

Or do you think it would be wiser to make like let say, 1,000 missions locally for initial version, then if it starts to pick up, next update add 1,000 more missions + bug fixes.
So then, just per update, make it read a database for the proper payment type, then pay the player from the database only.

EDIT: Reading the database isn’t my issue, I know how to do that. Just wondering how Client Side can understand the Info on the server and do the proper things locally by the info provided from the database. E.G. - Show the proper UI’s.

Well, first thing to do is not read the database at all from the client side Unity. Set up a web based API like REST, and have the Unity clients talk to the API over HTTPS and then have the ERST server connect to the database.

As for having enough information in the database, you can use multiple tables to express all of the data, and then use unique ID columns in each table. Have a TypeOfMissions table, and then have your MissionsList table contain a field called MissionTypeID (where that references a record in the TypeOfMissions table).

2 Likes

In addition to what is written above, you also probably want to define a class (not a MonoBehaviour) that matches the database table describing the missions. Copy database results into that class on the REST server (or into a list of them if your response will send back multiple missions). The response from the server would serialize the class or list to JSON. Then you put the same class file into your game, and deserialize it, and that’s how you get the information from the server to your clients.

Here’s a good starting point for learning REST. (MVC is not the best implementation but it works, you get it for free with .NET and VS, and the Interwebs are full of documentation and help using it … all you need to do is buy hosting with database support.)

1 Like

Thanks guys, looking into it now!

Is there any benefit to doing rest over standard PHP reading the database?
All the things I’m reading just makes it seem just another alternative, but is it really much more secure than PHP?

I wasn’t ever going to just give the client direct access to the Database. I have a PHP on a server, which leads to another PHP (So they don’t know the real link). Which reads the Database, which then gets sent to Unity.

So unless REST is like 10 fold more secure than PHP, I don’t see why I should use Rest when PHP can do it.

REST is a standard web API interface. You can use PHP (or ASP.NET) to implement a REST enabled site. It will be easier over the long run to use a standard like REST instead of doing a completely custom GET or POST through a page.

REST is how the client and server communicate – like HTTP (it actually is HTTP, and it’s how HTTP is supposed to work, not the broken garbage web servers commonly use nowadays). Something like PHP or ASP.NET MVC (or as I’ve done in the past for much more raw handling, ASP.NET ASHX) is how you implement REST or some other communications protocol.

If you’re going to use PHP, you probably want to find some type of REST library to work with so that you aren’t reinventing the wheel.

Security is a separate matter. REST is how the client and server talk to each other. Ideally you’ll have HTTPS to secure that “conversation” and then authentication (who are you?) and authorization (what can you do?) would be two additional concerns to sort out – often handled by the library or framework you choose, at least to some level.

1 Like