Reputation: 8202
So basically, I'm working on a console based game in C#. I'm to the point where I'm ready to save the data. I want all the data saved into one file, if possible. I don't wan't something like XML Serialization, where the player can just go in and give himself a million gold.
What should I use? Here's the things I need to serialize:
GameWorld
Inventory
Player
List<Item>
Point
List<String>
Here's the variables that are in the classes:
public class GameWorld
{
Dictionary<Point, Room>
}
public class Item
{
String Creator
String Verb
String RequiredItem
Action OnActivate
int Difficulty
Action OnDefeatEnemy
Action OnDefeatedByEnemy
}
public class Room
{
String Title
String Description
List<Item> Items
List<String> ItemNames
String Creator
}
public class Inventory
{
List<Items>
}
public enum ActionType
{
ACQUIRE_GOLD, DECREASE_HEALTH, INCREASE_HEALTH, DECREASE_STRENGTH, INCREASE_STRENGTH, GET_ITEM, PRINT_MESSAGE
}
public class Action
{
ActionType actionType
int Amount
String GiveItem
String Message
String Creator
bool SingleActivation
bool HasActivated
}
Upvotes: 2
Views: 4712
Reputation: 1408
If you're not worried about disclosure, you could just add a hash of [ your serialized data concatenated with some magic constant ]. A hacker would then have to disassemble your program to find the constant if they wanted to manipulate your serialized data.
If disclosure is a problem, then I would recommend "encryption" with a magic constant. This is really just a form of content scrambling, since the magic constant is "known" (although, perhaps a nuisance to find).
By the way, your problem is analogous to the DRM problem, which really is unsolvable unless you have complete control over the client platform. http://www.schneier.com/crypto-gram-0105.html#3
Upvotes: 0
Reputation: 8818
Its easier to manage stored object, programmatically, using embedded object database like Db4o or Eloquera.
Upvotes: 1
Reputation: 21873
You could pretty easily serialize to xml then encrypt it before saving it to a file.
Upvotes: 2
Reputation: 300539
Using Binary serialization would obfuscate slightly.
[It won't stop someone with Reflector and a bit of a poke around your code and data files though]
Upvotes: 3
Reputation: 2467
http://www.codeproject.com/KB/cs/objserial.aspx
Would that work for you?
Upvotes: 1