- Home /
turn based game over long time period
i have an idea for a simple turn based game. i would like to allow for players to stop and continue the game over days/weeks. i would prefer an android game. game progress and player ips could be simply saved in something as simple as a text document or string somewhere. my game could access and reload / connect when players open the game.
i am looking for advice on the simplest way where/how to store the data/string required?
Answer by Statement · Oct 09, 2015 at 08:53 PM
Expect that IP addresses change between runs.
System.IO.File to get file access.
Application.persistentDataPath to get file storage.
Simple text file methods to use are File.WriteAllText, File.ReadAllText.
i have used some of these commands youre mentioning in my last project. i know they dont work for webplayers. are you sure they work for android? if so that makes for a very easy answer for me!!!
also are you saying on reconnect that ip addresses change? So then would it make sence i should connect to the gamename and exchange if same player names are connected?
For webplayer, you could possibly get away with saving stuff in PlayerPrefs with GetString and SetString. If you want to save arbitrary binary data, base64 encode it first. There is a limit on how large the string can be, but IIRC it can be roughly 250 kB until things get nasty. I did some tests on this in 2009 so things may have changed since :-)
I'm saying expect that they will change between runs if you have pauses of days/weeks. It all depends on the network configuration (static/dynamic ip etc). Yes, it would make sense to use a unique identifier ins$$anonymous$$d of an IP which may change/get swapped etc.
As i understand @toddisarockstar's comment he only want to build for Android and was worried if file io will work there. So the straight answer is: Yes, you can create, read and write files on Android as long as you have permissions for the folder you want to write to / read from.
$$anonymous$$eep in $$anonymous$$d that Android is a Linux based OS. So file and folder names are case sensitive and use "/" ins$$anonymous$$d of "\".
To build valid files names you might want to use System.IO.Path.Combine.
very good info from Statement and bunny83 both. thanks guys! ideally i soppose it would be good to create a server and store there but thats a little ahead of me so i will be saving the server method for another day. I will be coding with the methods you guys describe!
Your answer
Follow this Question
Related Questions
Click to Change Public GameObject Variable 1 Answer
How to store player input in turn-based game? 0 Answers
TBG,If,While 1 Answer
Help with turn based Movement in a grid 2 Answers