Example #1
0
 private void Awake()
 {
     instance = this;
     if (MenuSoundFlag.instance != null)
     {
         if (MenuSoundFlag.instance.Muted)
         {
             Mute();
         }
     }
 }
Example #2
0
    void Inicio()
    {
        Scene scene = SceneManager.GetActiveScene();

        //Hacer modificacion en un futuro cuando esté el menu de juego.
        if (scene.name == "NivelTutorial" || scene.name == "Nivel1" || scene.name == "Nivel2" || scene.name == "NivelFinal")
        {
            Cursor.visible = true;
            Cursor.SetCursor(punterojuego, Vector2.one * (((float)punterojuego.width) / 2f), CursorMode.Auto);
            menuPausa = GameObject.Find("Camara").GetComponent <MenuPausa>();
            enJuego   = true;
        }
        else if (scene.name == "Inicio")
        {
            enJuego        = false;
            Cursor.visible = true;
            Cursor.SetCursor(punteroFueraJuego, Vector2.zero, CursorMode.Auto);
        }
        else
        {
            enJuego        = false;
            Cursor.visible = false;
        }
    }
Example #3
0
 private void Awake()
 {
     menuPausa = GetComponent <MenuPausa>();
 }
Example #4
0
    // Método para hacer que el personaje dispare objetos (en este caso disparará balas).
    private void atacarPersonaje()
    {
        if ((Input.GetMouseButton(0) || Input.GetKey(KeyCode.Z)) && !atacando && municion > 0 && !MenuPausa.getJuegoPausado())
        {
            atacando = true;
            sonidoDisparo.Play();
            municion -= 1;

            GameObject bala = null;
            switch (direccion)
            {
            case 0:
                bala = Instantiate(balaBuena, new Vector2(transform.position.x - 0.15f,
                                                          transform.position.y - 0.025f), Quaternion.identity);
                break;

            case 1:
                bala = Instantiate(balaBuena, new Vector2(transform.position.x - 0.15f,
                                                          transform.position.y - 0.029f), Quaternion.identity);
                break;

            case 2:
                bala = Instantiate(balaBuena, new Vector2(transform.position.x + 0.15f,
                                                          transform.position.y - 0.025f), Quaternion.identity);
                break;

            case 3:
                bala = Instantiate(balaBuena, new Vector2(transform.position.x + 0.15f,
                                                          transform.position.y - 0.029f), Quaternion.identity);
                break;
            }

            switch (direccion)
            {
            case 0:
                bala.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, -500));
                break;

            case 1:
                bala.GetComponent <Rigidbody2D>().AddForce(new Vector2(-500, 0));
                break;

            case 2:
                bala.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 500));
                break;

            case 3:
                bala.GetComponent <Rigidbody2D>().AddForce(new Vector2(500, 0));
                break;
            }

            StartCoroutine(tiempoEspera());  // Llama a una corrutina para hacer un tiempo de espera entre bala y bala.
        }
        else if ((Input.GetMouseButton(0) || Input.GetKey(KeyCode.Z)) && municion <= 0 && !MenuPausa.getJuegoPausado())
        {
            if (!sonidoSinMunicion.isPlaying)
            {
                sonidoSinMunicion.Play();
            }
        }
    }
 //----------------------------------------------------
 void Start()
 {
     _menuPausa = GameObject.Find("gameMaster").GetComponent <MenuPausa>();
 }
Example #6
0
 //---------------------------------------------------------------------------------------------
 void Start()
 {
     DontDestroyOnLoad(gameObject);
     _prota     = GameObject.Find("Prota").GetComponent <Prota>();
     _menuPausa = GameObject.Find("gameMaster").GetComponent <MenuPausa>();
 }
Example #7
0
 //Esta funcion esta definida para ejecutarse en un menu de pausa, reanuda el juego.
 public void Reanudar(MenuPausa menuPausa)
 {
     menuPausa.Reanudar();
 }