Game Development Reference
In-Depth Information
global economy. There is something you should keep in mind: it is a fairly common prac-
tice to create a separate Save model to save data.
Tip
Alternatively, it is also a good practice to have several save files, some of which you save
very frequently (game/world state) and others you only write when the player asks to (the
main save). The implementation comes down to your type of game and your saving/load-
ing needs.
To create a Save model based on our player class in the game, create a new script called
PlayerSaveState in Assets\Scripts\Classes and replace its contents with
the following code:
using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public struct PlayerSaveState {
public string Name;
public int Age;
public string Faction;
public string Occupation;
public int Level;
public int Health;
public int Strength;
public int Magic;
public int Defense;
public int Speed;
public int Damage;
public int Armor;
public int NoOfAttacks;
public string Weapon;
public Vector2 Position;
public List<string> Inventory;
}
Search WWH ::




Custom Search