HECHO EL GUARDADO SIIIIIIIIIIIII

Solo me falta para que vaya para cualquier nivel y no vaya solo para el primer nivel.
parent 974b8179
Showing with 65 additions and 18 deletions
...@@ -5,7 +5,10 @@ using UnityEngine.SceneManagement; ...@@ -5,7 +5,10 @@ using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour public class MainMenu : MonoBehaviour
{ {
public void PlayGame() { public void NewGame() {
Coleccionables.iniciali = false;
Coleccionables.Modificado();
SceneManager.LoadScene("SampleScene"); SceneManager.LoadScene("SampleScene");
} }
......
...@@ -7,6 +7,14 @@ using UnityEngine.UI; ...@@ -7,6 +7,14 @@ using UnityEngine.UI;
public class SeleccionNivel : MonoBehaviour public class SeleccionNivel : MonoBehaviour
{ {
public Text infoColecc; public Text infoColecc;
public Coleccionables GameManager;
private void Start()
{
GuardarYCargar.Cargar(GameManager, "slotColeccionables");
Coleccionables.CargarDatos();
Debug.Log("Cargando...");
}
void Update() void Update()
{ {
......
...@@ -2028,7 +2028,7 @@ MonoBehaviour: ...@@ -2028,7 +2028,7 @@ MonoBehaviour:
m_PersistentCalls: m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 572894596} - m_Target: {fileID: 572894596}
m_MethodName: PlayGame m_MethodName: NewGame
m_Mode: 1 m_Mode: 1
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}
......
...@@ -485,6 +485,18 @@ PrefabInstance: ...@@ -485,6 +485,18 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c299a511f2a249142ac36667ddcf3b49, type: 3} m_SourcePrefab: {fileID: 100100000, guid: c299a511f2a249142ac36667ddcf3b49, type: 3}
--- !u!114 &512889790 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3174322665456641310, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
m_PrefabInstance: {fileID: 512889789}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 94ed2c62992ea584eb669871b1668a3c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &687002374 --- !u!1 &687002374
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -814,6 +826,7 @@ MonoBehaviour: ...@@ -814,6 +826,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
infoColecc: {fileID: 2095981438} infoColecc: {fileID: 2095981438}
GameManager: {fileID: 512889790}
--- !u!1 &1498000566 --- !u!1 &1498000566
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -4,7 +4,7 @@ using UnityEngine; ...@@ -4,7 +4,7 @@ using UnityEngine;
public class Coleccionables : MonoBehaviour public class Coleccionables : MonoBehaviour
{ {
public bool inicializado = false; public bool inicializado = false; //NO TOCAR
public GameObject prefabColeccionable; public GameObject prefabColeccionable;
public bool NO_TOCAR_LAS_VARIABLES_DESDE_AQUI = true; public bool NO_TOCAR_LAS_VARIABLES_DESDE_AQUI = true;
...@@ -29,6 +29,7 @@ public class Coleccionables : MonoBehaviour ...@@ -29,6 +29,7 @@ public class Coleccionables : MonoBehaviour
public static Vector3[] pColecNivel1; //Si posicionesColecNivel1[i] = (0, 0, 0) ese coleccionable ya ha sido recogido public static Vector3[] pColecNivel1; //Si posicionesColecNivel1[i] = (0, 0, 0) ese coleccionable ya ha sido recogido
private static bool modificado = false; //Cada vez que modificas un dato de este script fuera tienes que llamar a su funcion private static bool modificado = false; //Cada vez que modificas un dato de este script fuera tienes que llamar a su funcion
private static bool cargarDatos = false; //Cada vez que uses la funcion de GuardarYCargar.Cargar(); hay que usar esta despues.
// Start is called before the first frame update // Start is called before the first frame update
void Awake() void Awake()
...@@ -48,7 +49,7 @@ public class Coleccionables : MonoBehaviour ...@@ -48,7 +49,7 @@ public class Coleccionables : MonoBehaviour
// { // {
enemigosTotales[0] = 2; enemigosTotales[0] = 2;
nombreImagenPartitura[0] = "Partitura-completa-1"; nombreImagenPartitura[0] = "Partitura-completa-1";
coleccTotales[0] = 5; //El ultimo coleccionable se consigue al derrotar a todos los enemigos coleccTotales[0] = 5; //El ultimo coleccionable se consigue al derrotar a todos los enemigos, asi que aqui abajo hay el numero de coleccTotales - 1 de coleccionables
posicionesColecNivel1[0] = new Vector3(-5.48f, 0.01f, 0); posicionesColecNivel1[0] = new Vector3(-5.48f, 0.01f, 0);
posicionesColecNivel1[1] = new Vector3(-3.08f, 0.01f, 0); posicionesColecNivel1[1] = new Vector3(-3.08f, 0.01f, 0);
posicionesColecNivel1[2] = new Vector3(-1.78f, -1.78f, 0); posicionesColecNivel1[2] = new Vector3(-1.78f, -1.78f, 0);
...@@ -84,9 +85,25 @@ public class Coleccionables : MonoBehaviour ...@@ -84,9 +85,25 @@ public class Coleccionables : MonoBehaviour
void Update() void Update()
{ {
if (cargarDatos) {
cTotales = coleccTotales;
cConseguidos = colecConseguidos;
eTotales = enemigosTotales;
eDerrotados = enemigosDerrotados;
vMostrada = ventanaMostrada;
nIPartitura = nombreImagenPartitura;
pColecNivel1 = posicionesColecNivel1;
iniciali = inicializado;
cargarDatos = false;
}
if (modificado) { if (modificado) {
coleccTotales = cTotales;
colecConseguidos = cConseguidos; colecConseguidos = cConseguidos;
enemigosTotales = eTotales;
enemigosDerrotados = eDerrotados; enemigosDerrotados = eDerrotados;
ventanaMostrada = vMostrada; ventanaMostrada = vMostrada;
posicionesColecNivel1 = pColecNivel1; posicionesColecNivel1 = pColecNivel1;
...@@ -101,4 +118,8 @@ public class Coleccionables : MonoBehaviour ...@@ -101,4 +118,8 @@ public class Coleccionables : MonoBehaviour
modificado = true; modificado = true;
} }
public static void CargarDatos() {
cargarDatos = true;
}
} }
...@@ -38,16 +38,18 @@ public class ZonaFinal : MonoBehaviour ...@@ -38,16 +38,18 @@ public class ZonaFinal : MonoBehaviour
Time.timeScale = 0; Time.timeScale = 0;
if (Coleccionables.cConseguidos[0] == Coleccionables.cTotales[0]) if (!Coleccionables.vMostrada[0] && Coleccionables.cConseguidos[0] == Coleccionables.cTotales[0])
{ {
canvasColecionableDesbloqueados.gameObject.SetActive(true); canvasColecionableDesbloqueados.gameObject.SetActive(true);
Sprite imagenPartitura = Resources.Load<Sprite>(Coleccionables.nIPartitura[0]); Sprite imagenPartitura = Resources.Load<Sprite>(Coleccionables.nIPartitura[0]);
SitioImagenPartitura.GetComponent<Image>().sprite = imagenPartitura; SitioImagenPartitura.GetComponent<Image>().sprite = imagenPartitura;
Coleccionables.vMostrada[0] = true;
Coleccionables.Modificado();
} }
else { else {
AbrirCanvasVictoria(); AbrirCanvasVictoria();
} }
GuardarYCargar.Guardar(colecto, "slotColeccionables");
} }
//Se abre al darle al boton siguiente desde el canvas "canvasColecionableDesbloqueados" o sino se han consguido todos los coleccionables //Se abre al darle al boton siguiente desde el canvas "canvasColecionableDesbloqueados" o sino se han consguido todos los coleccionables
......
...@@ -21,7 +21,7 @@ MonoBehaviour: ...@@ -21,7 +21,7 @@ MonoBehaviour:
m_ShowMode: 4 m_ShowMode: 4
m_Title: m_Title:
m_RootView: {fileID: 6} m_RootView: {fileID: 6}
m_MinSize: {x: 950, y: 300} m_MinSize: {x: 950, y: 394}
m_MaxSize: {x: 10000, y: 10000} m_MaxSize: {x: 10000, y: 10000}
--- !u!114 &2 --- !u!114 &2
MonoBehaviour: MonoBehaviour:
...@@ -47,7 +47,7 @@ MonoBehaviour: ...@@ -47,7 +47,7 @@ MonoBehaviour:
m_MinSize: {x: 681, y: 344} m_MinSize: {x: 681, y: 344}
m_MaxSize: {x: 12006, y: 8044} m_MaxSize: {x: 12006, y: 8044}
vertical: 0 vertical: 0
controlID: 132 controlID: 67
--- !u!114 &3 --- !u!114 &3
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
...@@ -218,7 +218,7 @@ MonoBehaviour: ...@@ -218,7 +218,7 @@ MonoBehaviour:
m_MinSize: {x: 406, y: 344} m_MinSize: {x: 406, y: 344}
m_MaxSize: {x: 8006, y: 8044} m_MaxSize: {x: 8006, y: 8044}
vertical: 1 vertical: 1
controlID: 58 controlID: 68
--- !u!114 &10 --- !u!114 &10
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
...@@ -243,7 +243,7 @@ MonoBehaviour: ...@@ -243,7 +243,7 @@ MonoBehaviour:
m_MinSize: {x: 406, y: 222} m_MinSize: {x: 406, y: 222}
m_MaxSize: {x: 8006, y: 4022} m_MaxSize: {x: 8006, y: 4022}
vertical: 0 vertical: 0
controlID: 59 controlID: 69
--- !u!114 &11 --- !u!114 &11
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
...@@ -336,19 +336,19 @@ MonoBehaviour: ...@@ -336,19 +336,19 @@ MonoBehaviour:
m_ShowAllHits: 0 m_ShowAllHits: 0
m_SearchArea: 1 m_SearchArea: 1
m_Folders: m_Folders:
- Assets/Prefabs - Assets/Scenes
m_ViewMode: 1 m_ViewMode: 1
m_StartGridSize: 64 m_StartGridSize: 64
m_LastFolders: m_LastFolders:
- Assets/Prefabs - Assets/Scenes
m_LastFoldersGridSize: -1 m_LastFoldersGridSize: -1
m_LastProjectPath: C:\Users\Colme\Documents\UnityProjects\ProyectoVideojuegos\Videojuegos_Proyecto m_LastProjectPath: C:\Users\Colme\Documents\UnityProjects\ProyectoVideojuegos\Videojuegos_Proyecto
m_LockTracker: m_LockTracker:
m_IsLocked: 0 m_IsLocked: 0
m_FolderTreeState: m_FolderTreeState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: de340000 m_SelectedIDs: 162b0000
m_LastClickedID: 13534 m_LastClickedID: 11030
m_ExpandedIDs: 000000004a2a000000ca9a3b m_ExpandedIDs: 000000004a2a000000ca9a3b
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
...@@ -377,7 +377,7 @@ MonoBehaviour: ...@@ -377,7 +377,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: 000000004a2a000056320000 m_ExpandedIDs: 000000004a2a0000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
...@@ -402,8 +402,8 @@ MonoBehaviour: ...@@ -402,8 +402,8 @@ MonoBehaviour:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_ResourceFile: m_ResourceFile:
m_ListAreaState: m_ListAreaState:
m_SelectedInstanceIDs: m_SelectedInstanceIDs: c2320000
m_LastClickedInstanceID: 0 m_LastClickedInstanceID: 12994
m_HadKeyboardFocusLastEvent: 1 m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c6230000 m_ExpandedInstanceIDs: c6230000
m_RenameOverlay: m_RenameOverlay:
...@@ -499,7 +499,7 @@ MonoBehaviour: ...@@ -499,7 +499,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: f09cffffc6a4fffff4a4fffffcadffff4aaeffff1eb6ffff42d7ffffd6dfffffb2e0ffff02eaffff1aeeffff8cfbffff24be0100 m_ExpandedIDs: 80e6feffaae6feff80effeff92effeffa2effeffd630ffff0031ffffd639ffffe839fffff839ffff3e4effff684effff4257ffff5857ffff6c57ffff108effffac8effffd6d1ffff8cfbffff9a3c0000c23c0000165900002e590000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
......
This diff could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment