Whats the best option for an item database for a single player game
I was going to use SQL as I know how to use it and that it can do everything I'd want it to do but I read online that you need an internet connection and to connect to a server for it to work which if true rules SQL out as I want this to be an offline game.
I need the item database to be able to be filtered through, i.e. if an Ice enemy is killed I want them to only drop an item which has the "Ice" element or if a "gunner" is killed I'll want them to only drop a gun and/or a ice gunner dropping only items which have both the "ice" and "gun" attributes.
I would also need it in separate tables/ lists so that columns which aren't applicable to different items aren't assigned a value to them. I.E. I might want in a table for bombs a column for the blast radius of the bomb, whereas obviously a helmet wouldn't have a variable for a blast radius. So it would make sense having them both in separate tables to be more efficient.
TL;DR
Should I use SQL, XML, JSON or other format to create my item database for an offline game in which the database can be filtered through by one or multiple different criteria to return a specific item and can be split into different tables relating to the different objects. I.E. if bombs need a blast radius variable and helmets don't, and there are 100 different helmets, it seems pointless and a waste of data writing out that each helmet has 0 blast radius.
Please check my answer. SteenPetersen's is definitely the wrong way to do it.
Answer by SteenPetersen · Jul 30, 2017 at 03:33 PM
You may want to take a read through this:
https://docs.unity3d.com/ScriptReference/PlayerPrefs.html
if its offline you can store all sorts of things there instead.
Is it applicable for creating a database with such filtering options that I need? If so thank you and even if not thanks for the quick response!
dependant on your architecture you can store anything as it simply store floats and ints and strings. so it should be easy to simply convert that information to whatever you want. much like a database would.
Remember to mark the question as correct, if it was, so others know this has been resolved. and , anytime, glad to help!
Okay thank you Steen! Final thing before I mark it as correct; would PlayerPrefs be preferable over SQL, X$$anonymous$$L and JSON in the instance I'm talking about. If so I will mark this as correct then take some serious time learning about it before I start coding it. Thanks again :)
@SteenPetersen @DAA$$anonymous$$CO This is a really bad idea.
Check my answer below
Answer by Spaniel · Nov 13, 2017 at 11:26 PM
I know this is old but SteenPetersen's answer is really incorrect. You want an item database. How on earth do you suggest effectively storing that in PlayerPrefs? PlayerPrefs is good for single values. Hell, you could serialize an entire class into it as I have done before, but it's not super effective and it's single threaded. Storing a huge item database in there is a terrible idea.
I've done an offline game and have used SQLite and had great success. You treat it like a database and can query it like one but it's all offline.
Check out: https://github.com/codecoding/SQLite4Unity3d
Your answer
Follow this Question
Related Questions
How to add item to inventory with these scripts 0 Answers
Security with android 1 Answer
Harcoding items vs using a JSON database 0 Answers
issues with SQLITE DB, Getting the next data in the same column? 0 Answers
can you read json file on android ? I have a thesis and it's not going well. 1 Answer