コード例 #1
0
        public GameDataScriptableObject BuildGameData()
        {
            GameDataScriptableObject gd = ScriptableObject.CreateInstance <GameDataScriptableObject>();

            gd.deathCount = deathCount;
            gd.maxScore   = maxScore;
            gd.maxWave    = maxWave;
            return(gd);
        }
コード例 #2
0
    /// <summary>
    /// Load save data from disk or create one if it doesn't exists
    /// </summary>
    public void LoadGameData()
    {
        Debug.Log("Loading game data...");
        if (File.Exists(Application.persistentDataPath + "/gamedata.dat"))
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream      fs = File.OpenRead(Application.persistentDataPath + "/gamedata.dat");

            GameDataSerializableWrapper gdsw = (GameDataSerializableWrapper)bf.Deserialize(fs);
            currentGameData = gdsw.BuildGameData();
            fs.Close();
            Debug.Log("Game data loaded!");
            return;
        }
        Debug.Log("No save file found!");
        CreateGameData();
        SaveGameData();
    }
コード例 #3
0
 public GameDataSerializableWrapper(GameDataScriptableObject gameData)
 {
     deathCount = gameData.deathCount;
     maxWave    = gameData.maxWave;
     maxScore   = gameData.maxScore;
 }
コード例 #4
0
 /// <summary>
 /// Create default game data
 /// </summary>
 /// <returns>Default game data</returns>
 public GameDataScriptableObject CreateGameData()
 {
     currentGameData = UnityEngine.Object.Instantiate <GameDataScriptableObject>(defaultGameData);
     return(currentGameData);
 }