public void SetupPlayer(SavedStats LoadedStats) { myStats.Health = LoadedStats.Health; myStats.Mana = LoadedStats.Mana; myStats.Experience = LoadedStats.Experience; myStats.Level = LoadedStats.Level; myStats.MaxHealth = LoadedStats.MaxHealth; myStats.MaxMana = LoadedStats.MaxMana; }
public virtual void SetStats(SavedStats stats) { hp = stats.hp; currentHP = hp; speed = stats.movementSpeed; atackSpeed = stats.atackSpeed; hpBar.maxValue = hp; hpBar.value = currentHP; }
public void LoadData() { //Load if the saves directory exists if (Directory.Exists("Saves")) { //create the binary formatter BinaryFormatter formatter = new BinaryFormatter(); //open the save file FileStream saveFile = File.Open("Saves/save.binary", FileMode.Open); //read the highscore savedStats = (SavedStats)formatter.Deserialize(saveFile); } }
public void Save(SavedStats stats) { //#if UNITY_ANDROID // //path = Application.persistentDataPath+ "!/assets/Resources/CharactersStats/"; // path = "jar:file://" + Application.persistentDataPath + "!/assets/"; //#endif //#if UNITY_ENGINE // path = Aplication.dataPath + "/ StreamingAssets/Resources/CharactersStats/"; //#endif // Debug.Log("Here"); //using (FileStream fileStream = new FileStream(path + stats.characterType + ".json", FileMode.Create)) //{ // using (StreamWriter writer = new StreamWriter(fileStream)) // { // writer.Write(jSon); // } //} }
public SavedStats LoadData(string fileName) { //#if UNITY_ANDROID // path = "jar:file://" + Application.dataPath + "!/assets/"; //#endif //#if UNITY_ENGINE // path = Aplication.dataPath //#endif Saver saver = GameObject.FindObjectOfType <Saver>(); SavedStats savedStats = null; string jSon = saver.ReturnFile(fileName); Debug.Log(jSon); savedStats = JsonUtility.FromJson <SavedStats>(jSon); return(savedStats); //if (File.Exists(path + fileName + ".json")) //{ // string jSon = File.ReadAllText(path + fileName + ".json"); // savedStats = JsonUtility.FromJson<SavedStats>(jSon); //} //return savedStats; }
public override void SetStats(SavedStats stats) { base.SetStats(stats); ammoSpeed = stats.ammoSpeed; ammoDamage = stats.ammoDamage; }
public override void SetStats(SavedStats stats) { base.SetStats(stats); damage = stats.damage; }
void SaveInPrefs(PrefsData data) { SavedStats currentSavedStats; string json = PlayerPrefs.GetString("SavedStats"); if (String.IsNullOrEmpty(json)) { currentSavedStats = new SavedStats(); } else { currentSavedStats = JsonConvert.DeserializeObject<SavedStats>(json); } currentSavedStats.stats.Add(data); PlayerPrefs.SetString("SavedStats", JsonConvert.SerializeObject(currentSavedStats)); }