// private void cargarJuego() { // int w = saveGame.heightmapW; // int h = saveGame.heightmapH; // Color[] pixels = new Color[w * h]; // for (int i = 0; i < w * h; i++) { // float temp = saveGame.heightmapData[i]; // pixels[i] = new Color(temp, temp, temp); // } // if (texturaBase.width != w || texturaBase.height != h) { // Debug.LogError("Las dimensiones de las texturas no coinciden!"); // } // texturaBase.SetPixels(pixels); // texturaBase.Apply(); // estado = 1; // } //Menus personalizados -------------------------------------------------------------------------------------------------------------------- private void menuPrincipal() { GUILayout.BeginArea(new Rect((float)cuantoW * 20.5f, cuantoH * 20, cuantoW * 7, cuantoH * 5)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent("Comenzar juego", "Comenzar un juego nuevo"), "boton_menu_1")) { pixels = new Color[texturaBase.width * texturaBase.height]; FuncTablero.inicializa(texturaBase); faseCreacion = 0; paso1Completado = false; // objetoRoca.renderer.enabled = true; objetoRoca.animation.Play("HologramaAparecer"); Camera.main.animation.Play("AcercarseHolograma"); estado = 5; } if (GUILayout.Button(new GUIContent("Cargar", "Acceder a las partidas guardadas"), "boton_menu_2")) { estado = 6; } if (GUILayout.Button(new GUIContent("Opciones", "Acceder a las opciones"), "boton_menu_3")) { // Camera.main.animation.Play("AcercarsePantalla"); estado = 2; } if (GUILayout.Button(new GUIContent("Cr\u00e9ditos", "Visualiza los cr\u00e9ditos"), "boton_menu_3")) //U+00E9 es el caracter unicode 'é' { estado = 3; } if (GUILayout.Button(new GUIContent("Salir", "Salir de este juego"), "boton_menu_4")) { estado = 4; } GUILayout.EndVertical(); GUILayout.EndArea(); }
private void creacionInicial() { Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando la creacion desde cero..."); //Trabajar con la textura Textura_Planeta y crear el mapa lógico a la vez Texture2D texturaBase = objetoRoca.renderer.sharedMaterial.mainTexture as Texture2D; Color[] pixels = new Color[texturaBase.width * texturaBase.height]; FuncTablero.inicializa(texturaBase); Debug.Log(FuncTablero.formateaTiempo() + ": Creando ruido..."); pixels = FuncTablero.ruidoTextura(); //Se crea el ruido para la textura base y normales... Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Suavizando polos y bordes..."); pixels = FuncTablero.suavizaBordeTex(pixels, texturaBase.width / 20); //Se suaviza el borde lateral... pixels = FuncTablero.suavizaPoloTex(pixels); //Se suavizan los polos... Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Aplicando cambios..."); texturaBase.SetPixels(pixels); texturaBase.Apply(); Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Extruyendo vertices de la roca..."); float extrusion = 0.45f; MeshFilter Roca = objetoRoca.GetComponent <MeshFilter>(); Mesh meshTemp = Roca.mesh; meshTemp = FuncTablero.extruyeVerticesTex(meshTemp, texturaBase, extrusion, objetoRoca.transform.position); Roca.mesh = meshTemp; Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Construyendo collider..."); //Se añade el collider aqui, para que directamente tenga la mesh adecuada objetoRoca.AddComponent <MeshCollider>(); objetoRoca.GetComponent <MeshCollider>().sharedMesh = meshTemp; Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Calculando y extruyendo vertices del oceano..."); MeshFilter Agua = objetoOceano.GetComponent <MeshFilter>(); Mesh meshAgua = Agua.mesh; meshAgua = FuncTablero.extruyeVerticesValor(meshAgua, FuncTablero.getNivelAgua(), extrusion, objetoOceano.transform.position); Agua.mesh = meshAgua; Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Rellenando detalles..."); //se ajusta la propiedad de nivel de agua del shader objetoOceano.renderer.sharedMaterial.SetFloat("_nivelMar", FuncTablero.getNivelAgua()); objetoOceano.renderer.sharedMaterial.SetFloat("_tamPlaya", FuncTablero.getTamanoPlaya()); Debug.Log(FuncTablero.formateaTiempo() + ": Terminado. Cargando texturas de habitats..."); //obtener la textura de habitats del array de materiales de roca. Habitats esta en la 1ª posicion. Texture2D texElems = objetoRoca.renderer.sharedMaterials[2].mainTexture as Texture2D; //Texture2D texPlantas = objetoRoca.renderer.sharedMaterials[2].mainTexture as Texture2D; Texture2D texHabitatsEstetica = objetoRoca.renderer.sharedMaterials[1].mainTexture as Texture2D; Texture2D texHabitats = objetoRoca.renderer.sharedMaterials[1].GetTexture("_FiltroTex") as Texture2D; Debug.Log(FuncTablero.formateaTiempo() + ": Terminado. Creando el tablero..."); Casilla[,] tablero = FuncTablero.iniciaTablero(texturaBase, texHabitats, texHabitatsEstetica, texElems, Roca.mesh, objetoRoca.transform.position); Debug.Log(FuncTablero.formateaTiempo() + ": Terminado. Creando Vida..."); vida = new Vida(tablero, objetoRoca.transform); Debug.Log(FuncTablero.formateaTiempo() + ": Completada la creacion del planeta."); }
private void creacionCarga(ValoresCarga contenedor) { Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando el script de carga de valores..."); Texture2D texBase = contenedor.texturaBase; FuncTablero.inicializa(texBase); Mesh rocaMesh = contenedor.roca; Mesh aguaMesh = contenedor.agua; float nivelAgua = contenedor.nivelAgua; float tamanoPlaya = contenedor.tamanoPlaya; //Trabajar con la textura Textura_Planeta y crear el mapa lógico a la vez Debug.Log(FuncTablero.formateaTiempo() + ": Aplicando textura de ruido..."); Texture2D texturaBase = objetoRoca.renderer.sharedMaterial.mainTexture as Texture2D; texturaBase = texBase; texturaBase.Apply(); Debug.Log(FuncTablero.formateaTiempo() + ": Asignando Mesh a la roca..."); MeshFilter Roca = objetoRoca.GetComponent <MeshFilter>(); Roca.mesh = rocaMesh; //Se añade el collider aqui, para que directamente tenga la mesh adecuada Debug.Log(FuncTablero.formateaTiempo() + ": Creando collider de la roca..."); objetoRoca.AddComponent <MeshCollider>(); objetoRoca.GetComponent <MeshCollider>().sharedMesh = rocaMesh; Debug.Log(FuncTablero.formateaTiempo() + ": Asignando Mesh al oceano..."); MeshFilter Agua = objetoOceano.GetComponent <MeshFilter>(); Agua.mesh = aguaMesh; Debug.Log(FuncTablero.formateaTiempo() + ": Completando detalles..."); //se ajusta la propiedad de nivel de agua del shader objetoOceano.renderer.sharedMaterial.SetFloat("_nivelMar", nivelAgua); objetoOceano.renderer.sharedMaterial.SetFloat("_tamPlaya", tamanoPlaya); Debug.Log(FuncTablero.formateaTiempo() + ": Cargando texturas de habitats..."); //obtener la textura de habitats del array de materiales de roca. Habitats esta en la 1ª posicion. objetoRoca.renderer.sharedMaterials[2].mainTexture = contenedor.texturaElementos; objetoRoca.renderer.sharedMaterials[1].mainTexture = contenedor.texturaHabsEstetica; Texture2D texHabitats = objetoRoca.renderer.sharedMaterials[1].GetTexture("_FiltroTex") as Texture2D; texHabitats = contenedor.texturaHabitats; objetoRoca.renderer.sharedMaterials[1].SetTexture("_FiltroTex", texHabitats); Debug.Log(FuncTablero.formateaTiempo() + ": Cargando la vida..."); vida = new Vida(contenedor.vida); vida.setObjetoRoca(objetoRoca.transform); Debug.Log(FuncTablero.formateaTiempo() + ": Carga completada."); }