private void Start() { HighScore score = SaveHighScore.LoadScore(); highScore = score.highScoreData; highScoreMain.text = highScore.ToString(); }
void Start() { Saving = new DataSaving(); save = Saving.Load(); score = 0; StartCoroutine(pauseStart()); }
// Use this for initialization void Start() { //lives = 3; saveScore = GetComponent <SaveHighScore> (); debryObject = DebryObject; saveScore.LoadHighScoreXML(); highScoreText.text = "" + highScore; //Debug.Log (CameraRotate.rotateSpeed); }
void Start() { cutSceneAnimator = GetComponent <Animator>(); cutSceneSource = GetComponent <AudioSource>(); Saving = new DataSaving(); save = Saving.Load(); scoreText.text = "Total Score\n------------\n" + Math.Round(save.OceanScore + save.SkyScore + save.SpaceScore); }
void Start() { HighScore score = SaveHighScore.LoadScore(); if (score == null) { highScore = 0; SaveHighScore.SaveScore(this); } FindObjectOfType <PlayerMove>().OnPlayerDeath += OnGameOver; //makes OnGameOver happen on the OnPlayerDeath event }
void Update() { currentScore = sc.currentScore; if (roundOver) { if (currentScore > SaveHighScore.highScore) { SaveHighScore.Save(currentScore); } } highScoreText.text = SaveHighScore.highScore.ToString(); }
//Load the file into SaveData. public SaveHighScore Load() { if (!File.Exists(Application.persistentDataPath + "/SaveData" + Name + ".dat")) { //Debug.Log("File Not Found! Load Failed."); return(null); } BinaryFormatter bf = new BinaryFormatter(); //Serializer FileStream file = File.Open(Application.persistentDataPath + "/SaveData" + Name + ".dat", FileMode.Open); //Open File SaveHighScore savedData = (SaveHighScore)bf.Deserialize(file); //Load Data. file.Close(); //Close File. return(savedData); //Return Saved Data. }
public void Save(SaveHighScore theClass) { ///Open or Create Save File //Debug.Log("Saving File to: " + Application.persistentDataPath + " ..."); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/SaveData" + Name + ".dat", FileMode.OpenOrCreate); //Create new SaveData. This will be everything that is saved. SaveHighScore saveData = theClass; bf.Serialize(file, saveData); file.Close(); }
/// <summary> /// Will reset all the scores in the location to 0 if you call this with true /// </summary> public void DeleteScores(bool actuallyDothis = false) { SaveHighScore s = new SaveHighScore(); s.SkyScore = 0; s.SpaceScore = 0; s.HighScoreName = ""; s.OceanScore = 0; s.TotalScore = 0; if (actuallyDothis) { Save(s); //Debug.Log("Deleted all saves! I hope you meant to do this!"); } }
private void Awake() { SaveData = new SaveHighScore(); try { SavedData data = new SavedData(); SaveHighScore oldScore = (SaveHighScore)data.Load(); HighScore = oldScore.highScore; data = null; } catch (System.NullReferenceException) { HighScore = 0; SaveData.SetHighScore(HighScore, HighScore); SavedData data = new SavedData(); data.Save(SaveData); } //Debug.Log("High Score: " + HighScore); }
/// <summary> /// Async saves a high score the players computer /// </summary> /// <param name="hs"></param> public void Save(SaveHighScore hs) { var ppath = Application.persistentDataPath; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (sender, args) => { string data = string.Format("{0}/GameData.dat", ppath); BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream fileSteam; try { if (File.Exists(data)) { File.WriteAllText(data, string.Empty); fileSteam = File.Open(data, System.IO.FileMode.Open); } else { fileSteam = File.Create(data); } binaryFormatter.Serialize(fileSteam, hs); fileSteam.Close(); if (Application.platform == RuntimePlatform.WebGLPlayer) { SyncFiles(); } } catch (Exception e) { Console.WriteLine(e); throw; } }; worker.RunWorkerAsync(); }
/// <summary> /// Returns the saved data from the unity path /// </summary> /// <returns></returns> public SaveHighScore Load() { var ppath = Application.persistentDataPath; SaveHighScore gameDetails = null; string dataPath = string.Format("{0}/GameData.dat", ppath); try { if (File.Exists(dataPath)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream fileStream = File.Open(dataPath, System.IO.FileMode.Open); gameDetails = (SaveHighScore)binaryFormatter.Deserialize(fileStream); fileStream.Close(); } } catch (Exception e) { PlatformSafeMessage("Failed to Load: " + e.Message); } return(gameDetails); }
void OnGameOver() { //change the screen gameOverScreen.SetActive(true); platforms.SetActive(false); //loads the previous high score HighScore score = SaveHighScore.LoadScore(); highScore = score.highScoreData; //checks to see if a new high score was reached if (highScore < Mathf.RoundToInt(Time.timeSinceLevelLoad)) { //saves a new high score highScore = Mathf.RoundToInt(Time.timeSinceLevelLoad); SaveHighScore.SaveScore(this); } //Display score for that round secondsSurvivedUI.text = Mathf.RoundToInt(Time.timeSinceLevelLoad).ToString(); //display the high score highScoreGameOver.text = highScore.ToString(); }
void Start() { SaveHighScore.Load(); }