Preparandome para meter el guardado y la carga.

Ahora se guardan los coleccionables que ya se han obtenido :D
parent 7b65ac75
Showing with 374 additions and 179 deletions
...@@ -68,7 +68,8 @@ ...@@ -68,7 +68,8 @@
<Compile Include="Assets\Player\Scripts\BalaGuitarra.cs" /> <Compile Include="Assets\Player\Scripts\BalaGuitarra.cs" />
<Compile Include="Assets\Player\Scripts\BalasGuitarra.cs" /> <Compile Include="Assets\Player\Scripts\BalasGuitarra.cs" />
<Compile Include="Assets\Player\Scripts\Player2D.cs" /> <Compile Include="Assets\Player\Scripts\Player2D.cs" />
<Compile Include="Assets\Scripts\ScriptColeccionables.cs" /> <Compile Include="Assets\Scripts\Coleccionables.cs" />
<Compile Include="Assets\Scripts\GuardarYCargar.cs" />
<Compile Include="Assets\Scripts\ZonaFinal.cs" /> <Compile Include="Assets\Scripts\ZonaFinal.cs" />
<None Include="Assets\MainMenu\TextMesh Pro\Resources\Shaders\TMP_SDF-Surface-Mobile.shader" /> <None Include="Assets\MainMenu\TextMesh Pro\Resources\Shaders\TMP_SDF-Surface-Mobile.shader" />
<None Include="Assets\MainMenu\TextMesh Pro\Resources\LineBreaking Leading Characters.txt" /> <None Include="Assets\MainMenu\TextMesh Pro\Resources\LineBreaking Leading Characters.txt" />
......
...@@ -8,8 +8,9 @@ public class SeleccionNivel : MonoBehaviour ...@@ -8,8 +8,9 @@ public class SeleccionNivel : MonoBehaviour
{ {
public Text infoColecc; public Text infoColecc;
private void Start() void Update()
{ {
infoColecc.text = Coleccionables.cConseguidos[0] + "/" + Coleccionables.cTotales[0];
//Coloco los coleccionables conseguidos en ese nivel //Coloco los coleccionables conseguidos en ese nivel
} }
......
...@@ -202,11 +202,15 @@ public class Player2D : MonoBehaviour ...@@ -202,11 +202,15 @@ public class Player2D : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision) private void OnTriggerEnter2D(Collider2D collision)
{ {
if (collision.tag == "Coleccionable") { if (collision.tag == "Coleccionable") {
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].colecConseguidos++;
Coleccionables.cConseguidos[0]++;
for (int i = 0; i < Coleccionables.pColecNivel1.Length; i++) {
if (Coleccionables.pColecNivel1[i] == collision.transform.position) { Coleccionables.pColecNivel1[i] = new Vector3(0, 0, 0); }
}
Coleccionables.Modificado();
Destroy(collision.gameObject); Destroy(collision.gameObject);
Debug.Log(ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].colecConseguidos+"/"+ Debug.Log(Coleccionables.cConseguidos[0] + "/" + Coleccionables.cTotales[0]);
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].coleccionables);
} }
} }
} }
...@@ -9,7 +9,7 @@ GameObject: ...@@ -9,7 +9,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 7736364748447018736} - component: {fileID: 7736364748447018736}
- component: {fileID: 7736364748447018739} - component: {fileID: 3174322665456641310}
m_Layer: 0 m_Layer: 0
m_Name: GameManager m_Name: GameManager
m_TagString: Untagged m_TagString: Untagged
...@@ -31,7 +31,7 @@ Transform: ...@@ -31,7 +31,7 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7736364748447018739 --- !u!114 &3174322665456641310
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -40,7 +40,22 @@ MonoBehaviour: ...@@ -40,7 +40,22 @@ MonoBehaviour:
m_GameObject: {fileID: 7736364748447018738} m_GameObject: {fileID: 7736364748447018738}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b22fee4fbe849e841b45124da9aad35b, type: 3} m_Script: {fileID: 11500000, guid: 94ed2c62992ea584eb669871b1668a3c, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
numeroDeNiveles: 1 prefabColeccionable: {fileID: 6914436123365519657, guid: bb9f2d39e14ac4c4493c44a6cc1ddc3b,
type: 3}
NO_TOCAR_LAS_VARIABLES_DESDE_AQUI: 1
numeroNiveles: 1
coleccTotales: 00000000
colecConseguidos: 00000000
enemigosTotales: 00000000
enemigosDerrotados: 00000000
ventanaMostrada: 00
nombreImagenPartitura:
-
posicionesColecNivel1:
- {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 0}
...@@ -840,7 +840,7 @@ Transform: ...@@ -840,7 +840,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1126699021 --- !u!1 &1126699021
GameObject: GameObject:
...@@ -1057,7 +1057,7 @@ RectTransform: ...@@ -1057,7 +1057,7 @@ RectTransform:
- {fileID: 572894595} - {fileID: 572894595}
- {fileID: 1605307418} - {fileID: 1605307418}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
...@@ -1302,7 +1302,7 @@ Transform: ...@@ -1302,7 +1302,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1521503612 --- !u!1 &1521503612
GameObject: GameObject:
...@@ -2077,3 +2077,72 @@ CanvasRenderer: ...@@ -2077,3 +2077,72 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1993095852} m_GameObject: {fileID: 1993095852}
m_CullTransparentMesh: 0 m_CullTransparentMesh: 0
--- !u!1001 &2037996321
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 7736364748447018738, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_Name
value: GameManager
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalPosition.x
value: -14.6
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalPosition.y
value: -0.04816645
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalPosition.z
value: -0.7089844
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c299a511f2a249142ac36667ddcf3b49, type: 3}
...@@ -341,7 +341,7 @@ Transform: ...@@ -341,7 +341,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &157140118 --- !u!1 &157140118
GameObject: GameObject:
...@@ -388,7 +388,6 @@ GameObject: ...@@ -388,7 +388,6 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 279354780} - component: {fileID: 279354780}
- component: {fileID: 279354781}
m_Layer: 5 m_Layer: 5
m_Name: LoadMenu m_Name: LoadMenu
m_TagString: Untagged m_TagString: Untagged
...@@ -417,19 +416,75 @@ RectTransform: ...@@ -417,19 +416,75 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &279354781 --- !u!1001 &512889789
MonoBehaviour: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} serializedVersion: 2
m_PrefabInstance: {fileID: 0} m_Modification:
m_PrefabAsset: {fileID: 0} m_TransformParent: {fileID: 0}
m_GameObject: {fileID: 279354779} m_Modifications:
m_Enabled: 1 - target: {fileID: 7736364748447018738, guid: c299a511f2a249142ac36667ddcf3b49,
m_EditorHideFlags: 0 type: 3}
m_Script: {fileID: 11500000, guid: 921e2ffaabada8447bb1cdad47959cf1, type: 3} propertyPath: m_Name
m_Name: value: GameManager
m_EditorClassIdentifier: objectReference: {fileID: 0}
infoColecc: {fileID: 0} - target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalPosition.x
value: -14.6
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalPosition.y
value: -0.04816645
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalPosition.z
value: -0.7089844
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7736364748447018736, guid: c299a511f2a249142ac36667ddcf3b49,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c299a511f2a249142ac36667ddcf3b49, type: 3}
--- !u!1 &687002374 --- !u!1 &687002374
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -512,7 +567,7 @@ MonoBehaviour: ...@@ -512,7 +567,7 @@ MonoBehaviour:
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 279354781} - m_Target: {fileID: 1420130837}
m_MethodName: BackMainMenu m_MethodName: BackMainMenu
m_Mode: 1 m_Mode: 1
m_Arguments: m_Arguments:
...@@ -643,7 +698,7 @@ Transform: ...@@ -643,7 +698,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1420130832 --- !u!1 &1420130832
GameObject: GameObject:
...@@ -679,7 +734,7 @@ RectTransform: ...@@ -679,7 +734,7 @@ RectTransform:
- {fileID: 1958144521} - {fileID: 1958144521}
- {fileID: 279354780} - {fileID: 279354780}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Coleccionables : MonoBehaviour
{
public bool inicializado = false;
public GameObject prefabColeccionable;
public bool NO_TOCAR_LAS_VARIABLES_DESDE_AQUI = true;
public int numeroNiveles = 1;
//Cambiar tamaño de los siguientes arrays a igual que el numeroNiveles
public int[] coleccTotales = new int[1];
public int[] colecConseguidos = new int[1];
public int[] enemigosTotales = new int[1];
public int[] enemigosDerrotados = new int[1];
public bool[] ventanaMostrada = new bool[1];
public string[] nombreImagenPartitura = new string[1];
public Vector3[] posicionesColecNivel1 = new Vector3[4]; //Si posicionesColecNivel1[i] = (0, 0, 0) ese coleccionable ya ha sido recogido
//Estas son las variables con las que trabajarán los demás scripts:
public static bool iniciali = false; //Poner en false al hacer nueva partida
public static int[] cTotales;
public static int[] cConseguidos;
public static int[] eTotales;
public static int[] eDerrotados;
public static bool[] vMostrada;
public static string[] nIPartitura;
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
// Start is called before the first frame update
void Awake()
{
if (!iniciali) {
inicializado = true;//NO TOCAR
iniciali = true;
for (int i = 0; i < numeroNiveles; i++) {
colecConseguidos[i] = 0;
enemigosDerrotados[i] = 0;
ventanaMostrada[i] = false;
}
//Habria que para cada nivel completar estas variables de cada array
// {
enemigosTotales[0] = 2;
nombreImagenPartitura[0] = "Partitura-completa-1";
coleccTotales[0] = 5; //El ultimo coleccionable se consigue al derrotar a todos los enemigos
posicionesColecNivel1[0] = new Vector3(-5.48f, 0.01f, 0);
posicionesColecNivel1[1] = new Vector3(-3.08f, 0.01f, 0);
posicionesColecNivel1[2] = new Vector3(-1.78f, -1.78f, 0);
posicionesColecNivel1[3] = new Vector3( 1.48f, -1.78f, 0);
// }
cTotales = coleccTotales;
cConseguidos = colecConseguidos;
eTotales = enemigosTotales;
eDerrotados = enemigosDerrotados;
vMostrada = ventanaMostrada;
nIPartitura = nombreImagenPartitura;
pColecNivel1 = posicionesColecNivel1;
}
}
private void Start()
{
for (int i = 0; i < pColecNivel1.Length; i++)
{
if (pColecNivel1[i] != new Vector3(0, 0, 0))
{
Instantiate(prefabColeccionable, pColecNivel1[i], Quaternion.identity);
}
}
Modificado();
}
// Update is called once per frame
void Update()
{
if (modificado) {
colecConseguidos = cConseguidos;
enemigosDerrotados = eDerrotados;
ventanaMostrada = vMostrada;
posicionesColecNivel1 = pColecNivel1;
inicializado = iniciali;
modificado = false;
}
}
//Si no se llama a esta función no se guardaran los datos correctamente
public static void Modificado() {
modificado = true;
}
}
fileFormatVersion: 2 fileFormatVersion: 2
guid: b22fee4fbe849e841b45124da9aad35b guid: 94ed2c62992ea584eb669871b1668a3c
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GuardarYCargar : MonoBehaviour
{
public static void Guardar(MonoBehaviour script, string nombreSlot) {
string queGuarda = JsonUtility.ToJson(script);
//Debug.Log(queGuarda);
PlayerPrefs.SetString(nombreSlot, queGuarda);
}
public static void Cargar(MonoBehaviour script, string nombreSlot) {
JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString(nombreSlot), script);
}
}
fileFormatVersion: 2
guid: eda6befa83a98db43b23d081ac612973
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScriptColeccionables : MonoBehaviour
{
//Forma de guardar los colecciobales que ya se han conseguido¿¿??
public struct VariablesNivel
{
public int enemigos; //El numero de enemigos a derrotar en el nivel para conseguir el coleccionable que se consigue por derrotar a todos los enemigos
public int enemigosDerrotados; //Al superar el nivel, si no se han derrotado todos los enemigos este debe volver a 0
public int coleccionables; //El numero de coleccionables que hay que conseguir para obtener una canción.
public int colecConseguidos; //Este valor debe mantenerse
public bool ventanaMostrada; //Te indica si ya se ha mostrado la ventana de que has conseguido la partitura de este nivel
public string rutaImagenPartitura; //Te indica donde está la imagen asociada a la partitura de este nivel
public VariablesNivel(int enemigosPorNivel_, int coleccionablesPorNivel_, string ruta)
{
enemigos = enemigosPorNivel_;
enemigosDerrotados = 0;
coleccionables = coleccionablesPorNivel_;
colecConseguidos = 0;
ventanaMostrada = false;
rutaImagenPartitura = ruta;
}
}
public int numeroDeNiveles = 1;
public static int nivelJugandoseAhora; //Es necesario indicar al script el nivel en el que nos encontramos o coger de donde sea el nivel actual
public static VariablesNivel[] variablesPorNivel;
void Start()
{
nivelJugandoseAhora = 0;
variablesPorNivel = new VariablesNivel[numeroDeNiveles];
//Hay que poner manualmente la cantidad de enemigos a derrotar, el numero de colecionables colocados y la ruta de la imagen
variablesPorNivel[0] = new VariablesNivel(3, 4, "Partitura-completa-1");
}
}
/**
*NOTAS PARA LOS DEMAS COMPIS DE EQUIPO:
* - Hay que indicar a "nivelJugandoseAhora" el nivel actual
* - Los coleccionables lleverán la etiqueta: "coleccionable"
* - Los enemigos llevarán la capa (layer) "Enemigo"
* - En el script del enemigo, cada vez que se derrote a uno, este tendrá un condicional que preguntará si es el último, en caso afirmativo, instanciara
* en su posicion un prefab del coleccionable. A su vez también mira que no se haya conseguido el extra antes, es decir, si hay 5 enemigos en total y
* en el array de enemigos derrotados aparece que han sido derrotados 5 significa que ya se derrotaron los cinco cuando se jugó al nivel anteriormente.
* Para evitar lios dejo aqui abajo el condicional que hay que poner para que solo se tenga que copiar y pegar donde indico.
* ESTE CONDICIONAL ESTÁ EN LA FUNCIÓN DONDE MUERE O SE DERROTA AL ENEMIGO QUE SEA
if (ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].enemigosDerrotados !=
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].enemigos)
{
if (ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].enemigosDerrotados ==
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].enemigos-1)
{
//AQUI SE INSTANCIA EL PREFAB DEL COLECCIONABLE
}
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].enemigosDerrotados++;
}
**/
...@@ -20,6 +20,7 @@ public class ZonaFinal : MonoBehaviour ...@@ -20,6 +20,7 @@ public class ZonaFinal : MonoBehaviour
public GameObject SitioImagenPartitura; public GameObject SitioImagenPartitura;
public Canvas canvasVictoria; public Canvas canvasVictoria;
public Text infoColeccionables; public Text infoColeccionables;
public Coleccionables colecto;
private void Start() private void Start()
{ {
...@@ -29,16 +30,18 @@ public class ZonaFinal : MonoBehaviour ...@@ -29,16 +30,18 @@ public class ZonaFinal : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision) private void OnTriggerEnter2D(Collider2D collision)
{ {
GuardarYCargar.Guardar(colecto, "slotColeccionables");
//Si el jugador entra aqui significa que se ha pasado el nivel. Parar el tiempo de juego, //Si el jugador entra aqui significa que se ha pasado el nivel. Parar el tiempo de juego,
//entonces mirar el tema de los coleccionables. //entonces mirar el tema de los coleccionables.
Time.timeScale = 0; Time.timeScale = 0;
if (ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].colecConseguidos == if (Coleccionables.cConseguidos[0] == Coleccionables.cTotales[0])
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].coleccionables)
{ {
canvasColecionableDesbloqueados.gameObject.SetActive(true); canvasColecionableDesbloqueados.gameObject.SetActive(true);
Sprite imagenPartitura = Resources.Load<Sprite>(ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].rutaImagenPartitura); Sprite imagenPartitura = Resources.Load<Sprite>(Coleccionables.nIPartitura[0]);
SitioImagenPartitura.GetComponent<Image>().sprite = imagenPartitura; SitioImagenPartitura.GetComponent<Image>().sprite = imagenPartitura;
} }
else { else {
...@@ -51,20 +54,18 @@ public class ZonaFinal : MonoBehaviour ...@@ -51,20 +54,18 @@ public class ZonaFinal : MonoBehaviour
public void AbrirCanvasVictoria() { public void AbrirCanvasVictoria() {
canvasColecionableDesbloqueados.gameObject.SetActive(false); canvasColecionableDesbloqueados.gameObject.SetActive(false);
canvasVictoria.gameObject.SetActive(true); canvasVictoria.gameObject.SetActive(true);
infoColeccionables.text = ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].colecConseguidos + "/" + infoColeccionables.text = Coleccionables.cConseguidos[0] + "/" + Coleccionables.cTotales[0] +" coleccionables encontrados";
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].coleccionables + " coleccionables encontrados";
if (ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].enemigosDerrotados != if (Coleccionables.eDerrotados[0] != Coleccionables.eTotales[0]) {
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].enemigos) {
//Este if hay que hacerlo siempre que se vaya a aumentar el contador de enemigo derrotado, para evitar que se den coleccionables extras //Este if hay que hacerlo siempre que se vaya a aumentar el contador de enemigo derrotado, para evitar que se den coleccionables extras
ScriptColeccionables.variablesPorNivel[ScriptColeccionables.nivelJugandoseAhora].enemigosDerrotados = 0; Coleccionables.eDerrotados[0] = 0;
} }
} }
public void VolverALaSeleccionDeNivel() { public void VolverALaSeleccionDeNivel() {
Time.timeScale = 1; Time.timeScale = 1;
SceneManager.LoadScene("MenuInicial");//CAMBIAR PARA QUE VAYA A LA SELECCION DE NIVEL SceneManager.LoadScene("SeleccionNivel");//CAMBIAR PARA QUE VAYA A LA SELECCION DE NIVEL
} }
public void ReiniciarNivel() { public void ReiniciarNivel() {
......
...@@ -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: 544} m_MinSize: {x: 950, y: 300}
m_MaxSize: {x: 10000, y: 10000} m_MaxSize: {x: 10000, y: 10000}
--- !u!114 &2 --- !u!114 &2
MonoBehaviour: MonoBehaviour:
...@@ -44,10 +44,10 @@ MonoBehaviour: ...@@ -44,10 +44,10 @@ MonoBehaviour:
y: 30 y: 30
width: 1920 width: 1920
height: 947 height: 947
m_MinSize: {x: 679, y: 494} m_MinSize: {x: 681, y: 344}
m_MaxSize: {x: 14002, y: 14044} m_MaxSize: {x: 12006, y: 8044}
vertical: 0 vertical: 0
controlID: 57 controlID: 132
--- !u!114 &3 --- !u!114 &3
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
...@@ -92,9 +92,9 @@ MonoBehaviour: ...@@ -92,9 +92,9 @@ MonoBehaviour:
x: 0 x: 0
y: 0 y: 0
width: 379 width: 379
height: 573 height: 605
m_MinSize: {x: 200, y: 200} m_MinSize: {x: 202, y: 222}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4002, y: 4022}
m_ActualView: {fileID: 15} m_ActualView: {fileID: 15}
m_Panes: m_Panes:
- {fileID: 15} - {fileID: 15}
...@@ -116,17 +116,17 @@ MonoBehaviour: ...@@ -116,17 +116,17 @@ MonoBehaviour:
m_Position: m_Position:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 573 y: 605
width: 1531 width: 1531
height: 374 height: 342
m_MinSize: {x: 232, y: 272} m_MinSize: {x: 102, y: 122}
m_MaxSize: {x: 10002, y: 10022} m_MaxSize: {x: 4002, y: 4022}
m_ActualView: {fileID: 13} m_ActualView: {fileID: 18}
m_Panes: m_Panes:
- {fileID: 13} - {fileID: 13}
- {fileID: 18} - {fileID: 18}
m_Selected: 0 m_Selected: 1
m_LastSelected: 1 m_LastSelected: 0
--- !u!114 &6 --- !u!114 &6
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
...@@ -215,8 +215,8 @@ MonoBehaviour: ...@@ -215,8 +215,8 @@ MonoBehaviour:
y: 0 y: 0
width: 1531 width: 1531
height: 947 height: 947
m_MinSize: {x: 404, y: 494} m_MinSize: {x: 406, y: 344}
m_MaxSize: {x: 10002, y: 14044} m_MaxSize: {x: 8006, y: 8044}
vertical: 1 vertical: 1
controlID: 58 controlID: 58
--- !u!114 &10 --- !u!114 &10
...@@ -239,11 +239,11 @@ MonoBehaviour: ...@@ -239,11 +239,11 @@ MonoBehaviour:
x: 0 x: 0
y: 0 y: 0
width: 1531 width: 1531
height: 573 height: 605
m_MinSize: {x: 404, y: 222} m_MinSize: {x: 406, y: 222}
m_MaxSize: {x: 8004, y: 4022} m_MaxSize: {x: 8006, y: 4022}
vertical: 0 vertical: 0
controlID: 15 controlID: 59
--- !u!114 &11 --- !u!114 &11
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
...@@ -262,7 +262,7 @@ MonoBehaviour: ...@@ -262,7 +262,7 @@ MonoBehaviour:
x: 379 x: 379
y: 0 y: 0
width: 1152 width: 1152
height: 573 height: 605
m_MinSize: {x: 200, y: 200} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 16} m_ActualView: {fileID: 16}
...@@ -320,9 +320,9 @@ MonoBehaviour: ...@@ -320,9 +320,9 @@ MonoBehaviour:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 646 y: 678
width: 1531 width: 1531
height: 355 height: 323
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_SearchFilter: m_SearchFilter:
m_NameFilter: m_NameFilter:
...@@ -336,20 +336,20 @@ MonoBehaviour: ...@@ -336,20 +336,20 @@ MonoBehaviour:
m_ShowAllHits: 0 m_ShowAllHits: 0
m_SearchArea: 1 m_SearchArea: 1
m_Folders: m_Folders:
- Assets/Scripts - Assets/Prefabs
m_ViewMode: 1 m_ViewMode: 1
m_StartGridSize: 64 m_StartGridSize: 64
m_LastFolders: m_LastFolders:
- Assets/Scripts - Assets/Prefabs
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: 96330000 m_SelectedIDs: de340000
m_LastClickedID: 13206 m_LastClickedID: 13534
m_ExpandedIDs: 00000000ce2b000000ca9a3b m_ExpandedIDs: 000000004a2a000000ca9a3b
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
...@@ -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: 00000000ce2b0000da330000 m_ExpandedIDs: 000000004a2a000056320000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
...@@ -492,14 +492,14 @@ MonoBehaviour: ...@@ -492,14 +492,14 @@ MonoBehaviour:
x: 0 x: 0
y: 73 y: 73
width: 379 width: 379
height: 554 height: 586
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_SceneHierarchy: m_SceneHierarchy:
m_TreeViewState: m_TreeViewState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: 96330000 m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: b4d5ffffe6d5ffff1cf4ffff78f9ffff36faffffc63e0000ca3e00001c3f00003e3f00001c400000204000002640000052400000 m_ExpandedIDs: f09cffffc6a4fffff4a4fffffcadffff4aaeffff1eb6ffff42d7ffffd6dfffffb2e0ffff02eaffff1aeeffff8cfbffff24be0100
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
...@@ -547,7 +547,7 @@ MonoBehaviour: ...@@ -547,7 +547,7 @@ MonoBehaviour:
x: 379 x: 379
y: 73 y: 73
width: 1150 width: 1150
height: 554 height: 586
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_ShowContextualTools: 0 m_ShowContextualTools: 0
m_WindowGUID: 43dad88c062228f459455f7a9fa529fd m_WindowGUID: 43dad88c062228f459455f7a9fa529fd
...@@ -559,9 +559,9 @@ MonoBehaviour: ...@@ -559,9 +559,9 @@ MonoBehaviour:
m_PlayAudio: 0 m_PlayAudio: 0
m_AudioPlay: 0 m_AudioPlay: 0
m_Position: m_Position:
m_Target: {x: 5.0414934, y: -3.0297124, z: -125.00155} m_Target: {x: 583.3709, y: 281.40454, z: -66.125}
speed: 2 speed: 2
m_Value: {x: 5.0414934, y: -3.0297124, z: -125.00155} m_Value: {x: 583.3709, y: 281.40454, z: -66.125}
m_RenderMode: 0 m_RenderMode: 0
m_CameraMode: m_CameraMode:
drawMode: 0 drawMode: 0
...@@ -594,9 +594,9 @@ MonoBehaviour: ...@@ -594,9 +594,9 @@ MonoBehaviour:
speed: 2 speed: 2
m_Value: {x: 0, y: 0, z: 0, w: 1} m_Value: {x: 0, y: 0, z: 0, w: 1}
m_Size: m_Size:
m_Target: 20.43228 m_Target: 664.04425
speed: 2 speed: 2
m_Value: 20.43228 m_Value: 664.04425
m_Ortho: m_Ortho:
m_Target: 1 m_Target: 1
speed: 2 speed: 2
...@@ -645,7 +645,7 @@ MonoBehaviour: ...@@ -645,7 +645,7 @@ MonoBehaviour:
x: 379 x: 379
y: 73 y: 73
width: 1150 width: 1150
height: 554 height: 586
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_VSyncEnabled: 0 m_VSyncEnabled: 0
m_MaximizeOnPlay: 0 m_MaximizeOnPlay: 0
...@@ -660,8 +660,8 @@ MonoBehaviour: ...@@ -660,8 +660,8 @@ MonoBehaviour:
vZoomLockedByDefault: 0 vZoomLockedByDefault: 0
m_HBaseRangeMin: -575 m_HBaseRangeMin: -575
m_HBaseRangeMax: 575 m_HBaseRangeMax: 575
m_VBaseRangeMin: -268.5 m_VBaseRangeMin: -284.5
m_VBaseRangeMax: 268.5 m_VBaseRangeMax: 284.5
m_HAllowExceedBaseRangeMin: 1 m_HAllowExceedBaseRangeMin: 1
m_HAllowExceedBaseRangeMax: 1 m_HAllowExceedBaseRangeMax: 1
m_VAllowExceedBaseRangeMin: 1 m_VAllowExceedBaseRangeMin: 1
...@@ -680,9 +680,9 @@ MonoBehaviour: ...@@ -680,9 +680,9 @@ MonoBehaviour:
x: 0 x: 0
y: 17 y: 17
width: 1150 width: 1150
height: 537 height: 569
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Translation: {x: 575, y: 268.5} m_Translation: {x: 575, y: 284.5}
m_MarginLeft: 0 m_MarginLeft: 0
m_MarginRight: 0 m_MarginRight: 0
m_MarginTop: 0 m_MarginTop: 0
...@@ -690,14 +690,14 @@ MonoBehaviour: ...@@ -690,14 +690,14 @@ MonoBehaviour:
m_LastShownAreaInsideMargins: m_LastShownAreaInsideMargins:
serializedVersion: 2 serializedVersion: 2
x: -575 x: -575
y: -268.5 y: -284.5
width: 1150 width: 1150
height: 537 height: 569
m_MinimalGUI: 1 m_MinimalGUI: 1
m_defaultScale: 1 m_defaultScale: 1
m_TargetTexture: {fileID: 0} m_TargetTexture: {fileID: 0}
m_CurrentColorSpace: 0 m_CurrentColorSpace: 0
m_LastWindowPixelSize: {x: 1150, y: 554} m_LastWindowPixelSize: {x: 1150, y: 586}
m_ClearInEditMode: 1 m_ClearInEditMode: 1
m_NoCameraWarning: 1 m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000 m_LowResolutionForAspectRatios: 01000000000000000000
...@@ -724,7 +724,7 @@ MonoBehaviour: ...@@ -724,7 +724,7 @@ MonoBehaviour:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 646 y: 678
width: 1531 width: 1531
height: 355 height: 323
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
sceneSetups: sceneSetups:
- path: Assets/Scenes/SampleScene.unity - path: Assets/Scenes/MenuInicial.unity
isLoaded: 1 isLoaded: 1
isActive: 1 isActive: 1
isSubScene: 0 isSubScene: 0
{"m_ExpandedPrefabGameObjectFileIDs":[],"m_ExpandedSceneGameObjectInstanceIDs":[],"m_ScrollY":0.0,"m_LastClickedFileID":7736364748447018738,"m_LastClickedInstanceID":0}
\ No newline at end of file
{"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":false,"audioPlay":false,"sceneViewState":{"showFog":true,"showMaterialUpdate":false,"showSkybox":false,"showFlares":true,"showImageEffects":true,"showParticleSystems":true},"in2DMode":true,"pivot":{"x":-14.600000381469727,"y":-0.04816645011305809,"z":-0.708984375},"rotation":{"x":0.0,"y":0.0,"z":0.0,"w":1.0},"size":22.0,"orthographic":true}
\ No newline at end of file
{"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":true,"audioPlay":false,"sceneViewState":{"showFog":true,"showMaterialUpdate":false,"showSkybox":true,"showFlares":true,"showImageEffects":true,"showParticleSystems":true},"in2DMode":true,"pivot":{"x":5.0414934158325199,"y":-3.029712438583374,"z":-125.00154876708985},"rotation":{"x":0.0,"y":0.0,"z":0.0,"w":1.0},"size":20.432279586791993,"orthographic":true} {"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":true,"audioPlay":false,"sceneViewState":{"showFog":true,"showMaterialUpdate":false,"showSkybox":true,"showFlares":true,"showImageEffects":true,"showParticleSystems":true},"in2DMode":true,"pivot":{"x":583.3709106445313,"y":281.404541015625,"z":-66.125},"rotation":{"x":0.0,"y":0.0,"z":0.0,"w":1.0},"size":664.0442504882813,"orthographic":true}
\ No newline at end of file \ No newline at end of file
Base path: C:/Program Files/Unity/Hub/Editor/2019.1.11f1/Editor/Data Base path: C:/Program Files/Unity/Hub/Editor/2019.1.11f1/Editor/Data
Cmd: initializeCompiler Cmd: initializeCompiler
Cmd: preprocess
insize=10875 outsize=4001 ok=1
Cmd: preprocess
insize=3615 outsize=2669 ok=1
Cmd: preprocess
insize=7844 outsize=2494 ok=1
Cmd: preprocess
insize=8019 outsize=2766 ok=1
Cmd: preprocess
insize=10864 outsize=3992 ok=1
Cmd: preprocess
insize=4453 outsize=3687 ok=1
Cmd: preprocess
insize=7870 outsize=2504 ok=1
c1cf21972190d082f35f9e468e1edf1b9390b571 0dd273e661f876bbf242a39b1a0f76aaca9171ca
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