Esempio n. 1
0
    private IEnumerator creacionParte3()
    {
        trabajando  = true;
        progreso    = 0.0f;
        GUI.enabled = false;
        Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando creacionParte3().");
        Debug.Log(FuncTablero.formateaTiempo() + ": Creando el tablero...");
        yield return(new WaitForSeconds(0.1f));

        Casilla[,] tablero = FuncTablero.iniciaTablero(texturaBase, texHabitats, texHabitatsEstetica, texElems, rocaMesh, Vector3.zero);
        progreso           = 0.7f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Creando la vida...");
        yield return(new WaitForSeconds(0.01f));

        vida     = new Vida(tablero);
        progreso = 1.0f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado creacionParte3().");
        yield return(new WaitForSeconds(0.01f));

        progreso     = 0.0f;
        GUI.enabled  = true;
        trabajando   = false;
        faseCreacion = 0;
        estado       = 1;
    }
Esempio n. 2
0
    private bool hechaCarga = false;                                                                            //Indica si se ha llevado a cabo una carga

    //Update y transiciones de estados -------------------------------------------------------------------------------------------------------

    void Awake()
    {
        Random.seed             = System.DateTime.Now.Millisecond;
        UnityEngine.Random.seed = System.DateTime.Now.Millisecond;
        Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando el script Principal...");
        //Se busca el objeto con los valores guardados en la escena inicial, si lo hubiera
        contenedor = GameObject.FindGameObjectWithTag("Carga");
        if (contenedor == null)                         //Si el objeto no existe, crear el planeta de cero
        {
            Debug.Log(FuncTablero.formateaTiempo() + ": No encontrado contenedor, iniciando creacion inicial...");
            creacionInicial();
            contenedor     = new GameObject("Contenedor");
            contenedor.tag = "Carga";
            contenedor.AddComponent <ValoresCarga>();
        }
        else                                                            //Si el objeto existe, cargar los valores necesarios
        {
            Debug.Log(FuncTablero.formateaTiempo() + ": Encontrado contenedor, cargando...");
            ValoresCarga cont = contenedor.GetComponent <ValoresCarga>();
            creacionCarga(cont);
            hechaCarga = true;
        }
        Debug.Log(FuncTablero.formateaTiempo() + ": Completada la creacion del planeta.");
        mejoras    = GameObject.FindGameObjectWithTag("Mejoras").GetComponent <MejorasNave>();
        interfaz   = gameObject.GetComponent <InterfazPrincipal>();
        materiales = GameObject.FindGameObjectWithTag("Materiales").GetComponent <Materiales> ();
    }
Esempio n. 3
0
    public float escalaTiempo = 1.0f;                                                                           //La escala temporal a la que se updateará todo

    //Tipos especiales ----------------------------------------------------------------------------------------------------------------------


    //Update y transiciones de estados -------------------------------------------------------------------------------------------------------

    void Awake()
    {
        Random.seed             = System.DateTime.Now.Millisecond;
        UnityEngine.Random.seed = System.DateTime.Now.Millisecond;
        Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando el script Pruebas. Creacion inicial...");
        creacionInicial();
        Debug.Log(FuncTablero.formateaTiempo() + ": Completada la creacion del planeta.");
    }
Esempio n. 4
0
    //Funciones basicas ----------------------------------------------------------------------------------------------------------------------

    void Awake()
    {
        Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando el metodo Awake() de la escena inicial...");
        miObjeto = this.transform;
        GameObject[] cadena = GameObject.FindGameObjectsWithTag("Carga");
        if (cadena.Length > 1)
        {
            contenedorTexturas = cadena[0];
            DontDestroyOnLoad(cadena[0]);
            for (int i = 1; i < cadena.Length; i++)
            {
                Destroy(cadena[i]);
            }
        }
        else
        {
            contenedorTexturas = cadena[0];
            DontDestroyOnLoad(cadena[0]);
        }
        if (PlayerPrefs.HasKey("MusicaOn"))
        {
            if (PlayerPrefs.GetInt("MusicaOn") == 1)
            {
                musicaOn = true;
            }
            else
            {
                musicaOn = false;
            }
        }
        if (PlayerPrefs.HasKey("MusicaVol"))
        {
            musicaVol = PlayerPrefs.GetFloat("MusicaVol");
        }
        if (PlayerPrefs.HasKey("SfxOn"))
        {
            if (PlayerPrefs.GetInt("SfxOn") == 1)
            {
                sfxOn = true;
            }
            else
            {
                sfxOn = false;
            }
        }
        if (PlayerPrefs.HasKey("SfxVol"))
        {
            sfxVol = PlayerPrefs.GetFloat("SfxVol");
        }
        SaveLoad.compruebaRuta();
        numSaves     = SaveLoad.FileCount();
        nombresSaves = new string[numSaves];
        nombresSaves = SaveLoad.getFileNames();
        objetoRoca.renderer.sharedMaterials[1].SetFloat("_nivelMar", nivelAguaInit);
        objetoRoca.renderer.sharedMaterials[1].SetFloat("_tamPlaya", tamanoPlayasInit);
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado el metodo Awake().");
    }
Esempio n. 5
0
    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.");
    }
Esempio n. 6
0
    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.");
    }
Esempio n. 7
0
    private IEnumerator creacionParte2()
    {
        trabajando  = true;
        progreso    = 0.0f;
        GUI.enabled = false;
        Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando creacionParte2().");
        yield return(new WaitForSeconds(0.1f));

        progreso = 0.1f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Instanciando la esfera roca...");
        yield return(new WaitForSeconds(0.01f));

        Mesh meshTemp = GameObject.Instantiate(meshEsfera) as Mesh;

        progreso = 0.2f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Extruyendo vertices de roca...");
        yield return(new WaitForSeconds(0.01f));

        meshTemp = FuncTablero.extruyeVerticesTex(meshTemp, texturaBase, 0.45f, new Vector3(0.0f, 0.0f, 0.0f));
        progreso = 0.6f;
        yield return(new WaitForSeconds(0.01f));

        rocaMesh = meshTemp;
        Debug.Log(FuncTablero.formateaTiempo() + ": Instanciando la esfera agua...");
        yield return(new WaitForSeconds(0.01f));

        Mesh meshAgua = GameObject.Instantiate(meshEsfera) as Mesh;

        progreso = 0.7f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Extruyendo vertices de agua...");
        yield return(new WaitForSeconds(0.01f));

        meshAgua = FuncTablero.extruyeVerticesValor(meshAgua, nivelAguaInit, 0.45f, new Vector3(0.0f, 0.0f, 0.0f));
        aguaMesh = meshAgua;
        progreso = 1.0f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completada creacionParte2().");
        yield return(new WaitForSeconds(0.01f));

        nombrePlaneta  = "PL" + Random.Range(1, 50000).ToString();
        nombreEstrella = "SP" + Random.Range(200, 6000).ToString();
        progreso       = 0.0f;
        trabajando     = false;
        GUI.enabled    = true;
        faseCreacion   = 2;
    }
Esempio n. 8
0
    private IEnumerator creacionParte1()
    {
        trabajando  = true;
        progreso    = 0.0f;
        GUI.enabled = false;
        Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando creacionParte1()...");
        yield return(new WaitForSeconds(0.1f));

        progreso = 0.1f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Creando ruido...");
        yield return(new WaitForSeconds(0.01f));

        pixels   = FuncTablero.ruidoTextura();                                                                                  //Se crea el ruido para la textura base y normales...
        progreso = 0.7f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Suavizando borde...");
        yield return(new WaitForSeconds(0.01f));

        pixels   = FuncTablero.suavizaBordeTex(pixels, texturaBase.width / 20);                 //Se suaviza el borde lateral...
        progreso = 0.8f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Suavizando polos...");
        yield return(new WaitForSeconds(0.01f));

        pixels   = FuncTablero.suavizaPoloTex(pixels);                                                                  //Se suavizan los polos...
        progreso = 0.9f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Aplicando cambios...");
        yield return(new WaitForSeconds(0.01f));

        texturaBase.SetPixels(pixels);
        texturaBase.Apply();
        progreso = 1.0f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completada creacionParte1().");
        yield return(new WaitForSeconds(0.01f));

        progreso        = 0.0f;
        trabajando      = false;
        GUI.enabled     = true;
        paso1Completado = true;
    }
Esempio n. 9
0
    void OnGUI()
    {
        GUI.skin = estiloGUI;
        GUI.Box(new Rect(cuantoW * 16, 0, cuantoW * 16, cuantoH * 8), "", "header_titulo");         //Header es 500x500px
        switch (estado)
        {
        case 0:                         //Menu principal
            menuPrincipal();
            break;

        case 1:                         //Comenzar
            Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando la carga de la siguiente escena...");
            ValoresCarga temp = contenedorTexturas.GetComponent <ValoresCarga>();
            temp.texturaBase = texturaBase;
            temp.texturaBase.Apply();
            temp.roca                = rocaMesh;
            temp.agua                = aguaMesh;
            temp.nivelAgua           = nivelAguaInit;
            temp.tamanoPlaya         = tamanoPlayasInit;
            temp.texturaElementos    = texElems;
            temp.texturaHabitats     = texHabitats;
            temp.texturaHabsEstetica = texHabitatsEstetica;
            temp.vida                = vida;
            temp.energia             = 200;
            temp.compBas             = 50;
            temp.compAdv             = 0;
            temp.matBio              = 0;
            temp.etapaJuego          = 0;
            Debug.Log(FuncTablero.formateaTiempo() + ": Valores cargados correctamente. Iniciando carga de nivel...");
            Application.LoadLevel("Escena_Principal");
            break;

        case 2:                         //Opciones
            menuOpciones();
            if (GUI.changed)
            {
                actualizarOpciones();
            }
            break;

        case 3:                         //Creditos
            creditos();
            break;

        case 4:                         //Salir
            PlayerPrefs.Save();
            Application.Quit();
            break;

        case 5:                         //Creacion
            if (faseCreacion == 0)
            {
                creacionParte1Interfaz();
            }
            else if (faseCreacion == 1)
            {
                creacionParte2Interfaz();
            }
            else if (faseCreacion == 2)
            {
                creacionParte3Interfaz();
            }
            break;

        case 6:                         //Cargar (seleccion)
            menuCargar();
            break;

        case 7:                         //Cargar (el juego seleccionado)
//				cargarJuego();
            Application.LoadLevel("Escena_Principal");
            break;
        }
        if (trabajando)
        {
            barraProgreso();
        }

        //Tooltip
        mostrarTooltip();
    }