public static void SavePlayer(GameMaster juego) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/player.noteToMySelf"; FileStream stream = new FileStream(path, FileMode.Create); InformacionDeJugar data = new InformacionDeJugar(juego); formatter.Serialize(stream, data); stream.Close(); }
public void PlayGame() { if (SavingSystem.CargarJugador() != null) { InformacionDeJugar data = SavingSystem.CargarJugador(); SceneManager.LoadScene(data.acto); cartasRecogidas = data.cartas; } else { SceneManager.LoadScene(1); cartasRecogidas = 0; } }
public static InformacionDeJugar CargarJugador() { string path = Application.persistentDataPath + "/player.noteToMySelf"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); InformacionDeJugar data = formatter.Deserialize(stream) as InformacionDeJugar; stream.Close(); return(data); } else { Debug.LogError("Documento no Encontrado"); return(null); } }
public void Setup() { InformacionDeJugar data = SavingSystem.CargarJugador(); if (data == null) { cloneplayer = Instantiate(player, transform.position, Quaternion.identity) as GameObject; cartasActivar = new int[30]; } else { Vector2 pos; pos.x = data.posicion[0]; pos.y = data.posicion[1]; transform.position = pos; cartasActivar = data.cartasActivarInventario; cloneplayer = Instantiate(player, transform.position, Quaternion.identity) as GameObject; for (int i = 0; i < cartasRecogidas; i++) { ActivarInventario(data.cartasActivarInventario[i]); CartasDestruir(data.cartasActivarInventario[i]); } } }