void Load()
        {
            var serializedInput = FileUtils.LoadTextFromFile(_fileName);

            if (string.IsNullOrEmpty(serializedInput))
            {
                _playerDataModel = new PlayerDataModel();
                _playerDataModel.Init();
                return;
            }

            _playerDataModel = JsonUtility.FromJson <PlayerDataModel>(serializedInput);
            if (_playerDataModel == null)
            {
                _playerDataModel = new PlayerDataModel();
                _playerDataModel.Init();
            }

            DaySwitcher.Instance.IsDay = _playerDataModel.isDay;

            if (_playerDataModel.langId != -1)
            {
                Lang.Instance.CurLang = ((SystemLanguage)_playerDataModel.langId);
            }
        }
        private void SaveToFile()
        {
            _playerDataModel        = GetPlayerData();
            _playerDataModel.isDay  = DaySwitcher.Instance.IsDay;
            _playerDataModel.langId = (int)Lang.Instance.CurLang;

            var serializedOutput = JsonUtility.ToJson(_playerDataModel);

            FileUtils.SaveTextToFile(_fileName, serializedOutput);

            Debug.Log("Save Game");
        }
Пример #3
0
        public void Save()
        {
            if (TheGame.GetComponent <GamePlayer>() == null)
            {
                return;
            }

            _playerDataModel        = TheGame.GetComponent <GamePlayer>().GetPlayerData();
            _playerDataModel.langId = (int)Lang.Instance.CurLang;

            var serializedOutput = JsonUtility.ToJson(_playerDataModel);

            FileUtils.SaveTextToFile(_fileName, serializedOutput);

            Debug.Log("Save Game");
        }
Пример #4
0
        public override void Init()
        {
            var playerData = TheGame.GetComponent <GameData>().GetPlayerData();

            _playerDataModel = playerData;
        }