public void LoadGame() { print("SC.Player1_Pos"); var xml = new XmlSerializer(typeof(Saveclass)); var SC = new Saveclass(); if (File.Exists(Application.dataPath + "/save/saver.xml")) { using (var stream = new FileStream(Application.dataPath + "/save/saver.xml", FileMode.Open, FileAccess.Read)) { SC = xml.Deserialize(stream) as Saveclass; } if (!Global.next_level_portal) { transform.position = SC.Player1_Pos[Global.level1]; } Global.next_level_portal = false; life = 3 - SC.Hearts; for (int i = 0; i < SC.Hearts; i++) { Hearts[i].SetActive(false); } points = SC.points; points_text.text = points.ToString(); } }
public void Save() { Saveclass savedata = new Saveclass(); savedata.inGameName = inGameName; savedata.soundMusic = soundMusic; savedata.soundSfx = soundSfx; File.WriteAllText(Application.persistentDataPath + "/GuardiansWar.txt", enc.Encrypt(JsonUtility.ToJson(savedata), "Keyword")); }
public void Load() { Saveclass managerscript = new Saveclass(); if (File.Exists(Application.persistentDataPath + "/GuardiansWar.txt")) { string text = File.ReadAllText(Application.persistentDataPath + "/GuardiansWar.txt"); managerscript = JsonUtility.FromJson <Saveclass>(enc.Decrypt(text, "Keyword")); inGameName = managerscript.inGameName; soundMusic = managerscript.soundMusic; soundSfx = managerscript.soundSfx; } }
public void Load() { var xml = new XmlSerializer(typeof(Saveclass)); var SC = new Saveclass(); SC.Hearts = 3; SC.Player1_Pos[Global.level1] = new Vector3(0.37f, 3f, -3.16f); if (!Directory.Exists(Application.dataPath + "/save")) { Directory.CreateDirectory(Application.dataPath + "/save"); } using (var stream = new FileStream(Application.dataPath + "/save/saver.xml", FileMode.Create, FileAccess.Write)) { xml.Serialize(stream, SC); } LoadGame(); }
public void Save() { var xml = new XmlSerializer(typeof(Saveclass)); var SC = new Saveclass(); SC.Hearts = Hearts.Length; SC.levels = Global.level1; SC.Player1_Pos[Global.level1] = transform.position; SC.points = points; if (!Directory.Exists(Application.dataPath + "/save")) { Directory.CreateDirectory(Application.dataPath + "/save"); } using (var stream = new FileStream(Application.dataPath + "/save/saver.xml", FileMode.Create, FileAccess.Write)) { xml.Serialize(stream, SC); } }