public void Cargar() { if (File.Exists(Application.persistentDataPath + "/bananasave.af")) { BinaryFormatter load = new BinaryFormatter(); FileStream file = File.OpenRead(Application.persistentDataPath + "/bananasave.af"); datos = load.Deserialize(file) as datosJuego; posicionGrandeX = datos.posicionGrandeX; posicionGrandeY = datos.posicionGrandeY; posicionGrandeZ = datos.posicionGrandeZ; posicionPequeñoX = datos.posicionPequeñoX; posicionPequeñoY = datos.posicionPequeñoY; posicionPequeñoZ = datos.posicionPequeñoZ; vecesVisto = datos.vecesVisto; coleccionables = datos.colecionables; nivel = datos.nivel; tiempoNivel = datos.tiempoNivel; tiempoTotal = datos.tiempoTotal; ManagerColeccionables.listaGuardar = datos.listaGuardar; SceneManager.LoadScene(nivel); desactivar.SetActive(true); GameObject.FindWithTag("Pequeño").transform.position = new Vector3(posicionPequeñoX, posicionPequeñoY, posicionPequeñoZ); GameObject.FindWithTag("Grande").transform.position = new Vector3(posicionGrandeX, posicionGrandeY, posicionGrandeZ); Pausa.vecesVisto = vecesVisto; Pausa.recogidos = coleccionables; } else { print("No existe archivo"); } }
void Awake() { #region DeleteOldGame if (File.Exists(Application.persistentDataPath + "/monosave.af")) { File.Delete(Application.persistentDataPath + "/monosave.af"); TTotal = 0; TNivel = 0; CColeccionable = 0; Pausa.recogidos = 0; Pausa.vecesVisto = 0; Timer.tiempoFunciona1 = true; for (int i = 0; i < ManagerColeccionables.listaGuardar.Length; i++) { ManagerColeccionables.listaGuardar[i] = true; } foreach (GameObject col in listaColeccionables) { col.SetActive(true); } } #endregion nivel = SceneManager.GetActiveScene().buildIndex; if (File.Exists(Application.persistentDataPath + "/bananasave.af") && SceneManager.GetActiveScene().buildIndex == 0) { BinaryFormatter load = new BinaryFormatter(); FileStream file = File.OpenRead(Application.persistentDataPath + "/bananasave.af"); datos = load.Deserialize(file) as datosJuego; nivel = datos.nivel; tiempoNivel = datos.tiempoNivel; tiempoTotal = datos.tiempoTotal; coleccionables = datos.colecionables; ManagerColeccionables.listaGuardar = datos.listaGuardar; } else if (!File.Exists(Application.persistentDataPath + "/bananasave.af") && SceneManager.GetActiveScene().buildIndex == 0) { for (int i = 0; i < ManagerColeccionables.listaGuardar.Length; i++) { ManagerColeccionables.listaGuardar[i] = true; } } NNivel = nivel; TTotal = tiempoTotal; TNivel = tiempoNivel; CColeccionable = coleccionables; }