/// <summary> /// /// </summary> /// <param name="gameSession"></param> private void PrepareSessionForSaving(GameSession gameSession) { this._tempChar = GameObject.FindGameObjectWithTag("Player").GetComponent <BaseCharacter>(); ClassMerger.MergeClassProperties(this._tempChar, gameSession.character); gameSession.lastSaveDate = DateTime.Now.ToString(); gameSession.ID = this.GetSavesNumber(); }
/// <summary> /// /// </summary> /// <param name="gameSession"></param> private void UpdateSession(GameSession gameSession) { this._tempChar = GameObject.FindGameObjectWithTag("Player").GetComponent <BaseCharacter>(); //Update player stats. ClassMerger.MergeClassProperties(gameSession.character, this._tempChar); //Update player position. this._tempChar.transform.position = gameSession.character.GetPosition(); this._tempChar.transform.rotation = Quaternion.Euler(gameSession.character.GetRotation()); }
/// <summary> /// /// </summary> /// <param name="settings"></param> private void SaveSettings(GameSettings settings) { this._tempSettings = new SavedSettings(); ClassMerger.MergeClassProperties(settings, this._tempSettings); this._file = File.Create(_settingsPath); this._binFormatter.Serialize(this._file, this._tempSettings); this._file.Close(); UnityEngine.Debug.Log("Data settings to path: " + _settingsPath); }
/// <summary> /// /// </summary> /// <returns></returns> private GameSettings LoadSettings() { GameSettings retSettings = new GameSettings(); this._tempSettings = null; if (File.Exists(_settingsPath)) { this._file = File.Open(_settingsPath, FileMode.Open); this._tempSettings = (SavedSettings)this._binFormatter.Deserialize(this._file); this._file.Close(); } else { this._tempSettings = new SavedSettings(); UnityEngine.Debug.LogWarning("No settings found, default ones loaded"); } ClassMerger.MergeClassProperties(this._tempSettings, retSettings); return(retSettings); }