Ejemplo n.º 1
0
    void Start()
    {
        this.mostrarPublicidad();                 //publicidad
        //cargarValores(); //carga los valores de x ej si se va a escuchar la musica
        this.nivel = PlayerPrefs.GetInt("nivel"); //traigo de disco el nivel con el que va a empezar el juego
        int      nivelContinuar = PlayerPrefs.GetInt("continuarNivel");
        TextMesh txtNivel       = GameObject.Find("txtNivel").GetComponent <TextMesh>();

        txtNivel.text = "level=" + nivel.ToString(); //solo es para mostrar el nivel
        this.vidas    = PlayerPrefs.GetInt("vidas"); //asigno la cantidad de vidas
        this.bloques  = 40;                          //pongo un valor falso para que no de error el juego
        this.cargarVidas();
        Time.timeScale = 1f;
        this.instanciador();                   //crea objetos
        if (nivelContinuar != 0 && nivel == 0) //si el nivel es distinto de cero significa que el usuario puso GUARDAR
        {
            crearNiveles scriptCrearNiveles = GameObject.Find("crear").GetComponent <crearNiveles>();
            vidas = PlayerPrefs.GetInt("vidasGuardadas");
            scriptCrearNiveles.continuarJuego();
            nivel         = nivelContinuar;
            txtNivel.text = "level=" + nivel.ToString();
            PlayerPrefs.SetInt("continuarNivel", 0);
        }
        else if (PlayerPrefs.GetInt("esNivelJefe") == 0)
        {
            this.cargarProximoNivel();
        }
        PlayerPrefs.SetInt("esNivelJefe", 0);//asi ya no va a volver a ser nivel jefe
    }
Ejemplo n.º 2
0
    // guardarJuego = guarda la partida en el disco para poder continuarla despues
    public void guardarJuego()
    {
        Pelota pelota = GameObject.Find("pelota").GetComponent <Pelota>();//busca el objeto

        if (pelota.transform.position.y >= 0)
        {
            GM.esteObjeto.mostrarPublicidad();
            //guardar un string con los bloques q se rompieron y al poner "guardar"
            //guardar ese sting en el disco y modificar las funciones correspondientes

            /*otra opcion ir guardando en un string cuando se rompe un bloque con su color y pos
             * y al apretar guardar se guarda ese string en disco luego al cargar se carga el nivel
             * completo pero se lee el archivo guardado y se destruyen los bloques q indiquen(hacerlo antes
             * de asignar las capsulas)*/

            GM scriptGM = GameObject.Find("GM").GetComponent <GM>();
            PlayerPrefs.SetInt("continuarNivel", scriptGM.nivel);
            PlayerPrefs.SetInt("vidasGuardadas", scriptGM.vidas);
            //File.Delete(Application.persistentDataPath + "/saves/slot1.bin");
            crearNiveles scriptCrearNiveles = GameObject.Find("crear").GetComponent <crearNiveles>();
            Time.timeScale = 1;
            fpausa         = false;
            if (scriptCrearNiveles.guardarJuego())
            {
                SceneManager.LoadScene("menuPrincipal");
            }
        }
        else
        {
            Time.timeScale = 1;
            fpausa         = false;
            Scanvas.esteObjeto.slider.gameObject.GetComponent <Slider>().enabled = true;
        }
    }
Ejemplo n.º 3
0
    public void OnButtonClick()
    {
        scriptMantenerColor = GameObject.Find("crear").GetComponent <mantenerColor>();//busca el objeto del script y lo asigna a la variable
        var go = EventSystem.current.currentSelectedGameObject;

        componenteImagen = GetComponent <Button>();
        botonCrear scriptBotonCrear = GameObject.Find(go.name).GetComponent <botonCrear>(); //le paso el nombre asi busca el objeto boton para traer su componente

        scriptBotonCrear.nColor = scriptMantenerColor.color;                                //HAY QUE TRAER ESTA MIERDA TODO HAY QUE TRAER SINO NO LO GUARDA!!
        crearNivel = GameObject.Find("crear").GetComponent <crearNiveles>();                //busca el objeto del script y lo asigna a la variable

        crearNivel.guardarBloque(go.name, scriptMantenerColor.color);                       //SIEMPRE HAY QUE BUSCAR ANTES EL OBJETO SINO NO FUNCIONA!!-------------------------------------------
    }
Ejemplo n.º 4
0
    void Start()
    {
        capsulasTotalesExistentes = contCapsulas.esteObjeto.capsulasTotales;
        cargarVectores();

        if (esteObjeto == null)
        {
            esteObjeto = this;
        }
        else if (esteObjeto != this)
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 5
0
    void Update()
    {
        componenteImagen = GetComponent <Button>();
        crearNiveles scriptCrearNiveles = GameObject.Find("crear").GetComponent <crearNiveles>();
        Material     mColor             = scriptCrearNiveles.naranja;

        switch (nColor)
        {
        case 0:
            componenteImagen.image.color = new Color32(208, 233, 191, 55);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 1:
            componenteImagen.image.color = Color.red;       //objeto buton del boton.componente del buton.parametro color
            break;

        case 2:
            componenteImagen.image.color = Color.green;       //objeto buton del boton.componente del buton.parametro color
            break;

        case 3:
            componenteImagen.image.color = Color.blue;       //objeto buton del boton.componente del buton.parametro color
            break;

        case 4:
            componenteImagen.image.color = Color.yellow;       //objeto buton del boton.componente del buton.parametro color
            break;

        case 5:
            componenteImagen.image.color = new Color32(255, 153, 0, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 6:
            componenteImagen.image.color = new Color32(150, 84, 0, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 7:
            componenteImagen.image.color = new Color32(7, 114, 7, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 8:
            componenteImagen.image.color = new Color32(0, 234, 255, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 9:
            componenteImagen.image.color = new Color32(251, 154, 255, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 10:
            componenteImagen.image.color = new Color32(229, 0, 116, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 11:
            componenteImagen.image.color = new Color32(255, 255, 255, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 12:
            componenteImagen.image.color = new Color32(141, 141, 141, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 13:
            componenteImagen.image.color = new Color32(0, 0, 0, 255);       //objeto buton del boton.componente del buton.parametro color
            break;

        case 14:
            //componenteImagen.image.color = new Color32(128, 111, 111, 255);   //objeto buton del boton.componente del buton.parametro color
            break;
        }
    }
Ejemplo n.º 6
0
    public void cargarProximoNivel()
    {
        crearNiveles scriptCrearNiveles = GameObject.Find("crear").GetComponent <crearNiveles>();

        scriptCrearNiveles.cargar();
    }