public void WriteSettings() { GameDataWriter gameDataWriter = new GameDataWriter(); GameDataReader gameDataReader = new GameDataReader(); GameData gameData = new GameData(); gameData.Effect = float.Parse(_audio.value.ToString()); gameData.Music = float.Parse(_music.value.ToString()); gameData.GamesPlayed = gameDataReader.GetGameData().GamesPlayed - 1; gameData.BestTime = gameDataReader.GetGameData().BestTime; gameDataWriter.WriteGameData(gameData); ReturnToMainMenu(); }
void WriteGameData() { ScoreManager scoreManager = GetComponent <ScoreManager>(); CoinStash coinStash = GetComponent <CoinStash>(); GameDataWriter gameDataWriter = new GameDataWriter(); GameDataReader gameDataReader = new GameDataReader(); GameData gameData = new GameData(); gameData.Highscore = scoreManager.GetScore(); gameData.Coins = coinStash.GetCoins(); gameData.BestTime = _timer.GetTimeElapsed(); gameData.Music = gameDataReader.GetGameData().Music; gameData.Effect = gameDataReader.GetGameData().Effect; gameDataWriter.WriteGameData(gameData); }
void Start() { if (!PlayerPrefs.HasKey("gs^2_catastrophe_firstRun")) { GameDataWriter gameDataWriter = new GameDataWriter(); GameData gameData = new GameData(); gameData.Music = 1; gameData.Effect = 1; gameData.Coins = 0; gameData.BestTime = "00:00"; gameData.GamesPlayed = 0; gameData.Highscore = 0; PlayerPrefs.SetInt("gs^2_catastrophe_firstRun", 1); gameDataWriter.WriteGameData(gameData); } else { Destroy(gameObject); } }