Hello guys, this is not the first course that I bought on this platform, I don’t know English, this problem has always been, but it was not critical, visually I understood everything. I bought this course only to study the save system in the game, and I absolutely do not understand anything, the scripts change many times and I do not understand what is happening at all,
maybe you have this closed course on youtube or maybe you have a text script from the lessons so i can translate it? This topic of the lesson is difficult in itself, but if do not understand the language, this topic becomes unattainable(
I thought about a similar solution, but it is not very profitable, a huge number of errors can turn the whole meaning of the text(
Unfortunately, this is a problem with almost any automatic translation service. Many of the terms are technical and easily mistranslated.
if your primary interest is in the saving system, you might try my port of the saving system ffrom BinaryFormatter to Json SavingSystem
Thanks, I looked at your posts, it looks a bit complicated, are you saying that BinaryFormatter is now unsafe to use? Does this apply to online games or offline too? I thought offline games couldn’t be made safe. It’s just that I don’t make a game that is on the course, I bought the course just for the save lesson, I make a turn-based strategy + RPG,
with a large number of unique units, each unit has characteristics, this is the level, attack, health, and so on … the level will grow and other parameters will grow along with it, using the system that is in your course, I figured out how I can save a separate field, such as position or health,
but in my game there is a class containing the parameters that I wrote about above, and I need to save several parameters at once in one class, and since this was not in the lesson, I don’t understand how to save it. I think I need to create an array or a list, but I don’t understand how to format it correctly
I did it now and have not checked it yet, it looks very primitive, but this is the only thing that came to my mind, to save three fields at once … another option is to create a class in which to specify 3 fields, in the Capture method create an instance of this class, assign it the values of my fields, and then save an instance of this class and get it too
Yes, this is the way we save it using the save system. Either an array, or a dictionary, or a class/struct. Your fields may not always be of the same type, so an array won’t always work
[System.Serializable]
struct SaveRecord
{
public int health;
public int attackOrHealAmount;
public int attackDistance;
}
public object CaptureState()
{
stats = new SaveRecord
{
health = health,
attackOrHealAmount = attackOrHealAmount,
attackDistance = attackDistance
};
return stats;
}
public void RestoreState(object state)
{
var record = (saveRecord)state;
health = record.health;
attackOrHealAmount = record.attackOrHealAmount;
attackDistance = record.attackDistance;
}
Thanks a lot for the clarification, it looks a lot clearer now. Now only one question remains, do I need to change the system from BinaryFormatter to Json? Or for offline play it will not matter?
The problem is that code can be injected into the binary when binary formatted. If it’s offline, it should be ok.
Thanks for your reply, I’ll try to look into this issue
Hello. Sorry to bother you, but I need help again. This method suited me for implementation via BinaryFormatter, but since this method is not safe, I decided to redo everything via Newtonsoft-Json as in the method that was sent to me below. For single targets this seems to work,
but for a list of data, I don’t know how to properly process the data with the class constructor that I did for this. Can you help me?
By trying everything in a row, it seems that I managed to make a working version, but I’m not sure if this is the correct form
This looks correct.
Good news, thanks
Looks like you are getting the hang of it!
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.