so quick rundown, im currently building a MVP for a text based adventure game for ym dnd players who havent had tabletop in a while.
i have all the systems working so far but one of the biggies i havnt done is saving/loading the game (or more accurately the players character data).
i WAS trying binary serialization but have since given up in favor of XML but my experiments so far have revealed that i have NO IDEA what im doing.
can anyone run me through understanding what i need to do please? (assume i dont know anything about xml saving.
|
V my player class (minus the methods and getters/setters)
EDIT:
i'm learnign with the basics of streamWriter and StreamReader and was making progress when i started getting "IOException: The process cannot access the file 'D:\test\Game1.txt' because it is being used by another process." for files that it's creating and i dont understand whats causing it as there is no apparent cause, it was literally fine and then BOOM cant access anymore.
EDIT-EDIT: figured out the problem and got this critical system for my MVP working as required, wanna thank J.Salas as the link actually did help me towards the right answer, everyone else wernt any help.
but for future referance for anyone having the same problem: dont create static writer/reader for your data saving, if they point to the same file they prevent each other from working, i simply create them inside the save/load methods and it works like a charm.
additionally the StreamWriter.WriteLine()/StreamReader.ReadLine() method operate 1 line at a time and will move onto the next line when called, the path can be a full filepath for a very specific place or just "game1.xml" if you wanna have the files be created in the games default folder.
(look how easy it was to explain the basics fo how this works? just do this instead of linking to much less helpful google searches anyone can find)