예제 #1
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "MainCamera" && coleccionables.ankh)
     {
         if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))
         {
             Debug.Log("Mirando a Pedestal de Ankh");
             imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);
             inventario invent = GameObject.Find("Inventario").GetComponent <inventario>();
             if (Input.GetMouseButtonDown(0) && invent.IsSeleccionado("ankh"))
             {
                 coleccionables.SendMessage("ColocaAnkh");
                 invent.QuitarObjeto("ankh");
                 Destroy(gameObject);
                 if (coleccionables.horusColocado)
                 {
                     puertaPiramide.SendMessage("Abrir");
                 }
                 imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
             }
         }
         else
         {
             imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
         }
     }
 }
예제 #2
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "MainCamera" && coleccionables.monedas)
     {
         if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))
         {
             Debug.Log("Mirando a máquina de café");
             imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);
             inventario invent = GameObject.Find("Inventario").GetComponent <inventario>();
             if (Input.GetMouseButtonDown(0) && invent.IsSeleccionado("monedas"))
             {
                 invent.QuitarObjeto("monedas");
                 //Sonido
                 PlaySound();
                 //Fin sonido
                 Destroy(gameObject, 0.4f);
                 imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
                 coleccionables.SendMessage("CambiaEscena");
                 //SceneManager.LoadScene ("Mundo1");
             }
         }
         else
         {
             imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
         }
     }
 }
예제 #3
0
    public Image imagenInteractuar;                     //ImagenInteractuar es la imagen de la mano que se muestra al poder interactuar con un objeto

    void OnTriggerStay(Collider other)
    {
        if (other.tag == "MainCamera")
        {
            if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))                //Al entrar en el collider, comprobamos si estamos mirando al objeto con el que hay que interactuar mediante un Raycasting desde la cámara
            {
                Debug.Log("Mirando a ankh");                                                                    //Si es así:
                imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);                                            //Mostramos la imagen de la mano, para que el jugador sepa que puede interactuar con un objeto
                inventario invent = GameObject.Find("Inventario").GetComponent <inventario> ();                 //Si es un puzzle para el que es necesario un objeto concreto, necesitaremos el objeto inventario
                if (Input.GetMouseButtonDown(0))
                {
                    if (!invent.IsSeleccionado("palanca"))                                                      //Si no tenemos el objeto seleccionado, el jugador dice que necesita ese objeto
                    {
                        StartCoroutine(ShowMessage("Voy a necesitar algo para arrancarlo.", 4));
                    }
                    else                                                                                        //Si lo tiene seleccionado:
                    //Sonido
                    {
                        PlaySound();                                                                            //Suena un efecto de sonido, para que el jugador sepa que ha interactuado con el objeto
                        //Fin sonido
                        coleccionables.SendMessage("ActivaAnkh");                                               //Cambia la variable booleana del script Coleccionables
                        Destroy(transform.parent.gameObject, 0.2f);                                             //Destruye el objeto padre del Trigger, para no poder volver a interactuar con el objeto
                        invent.QuitarObjeto("palanca");                                                         //Quita/añade objetos al inventario si procede
                        invent.AñadirObjeto("ankh");
                        imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);                                    //Pone la imagen de la mano totalmente invisible
                    }
                }
                else
                {
                    imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);                                        //Si estás en el collider pero no mirando al objeto, transparenta la imagen de la mano
                }
            }
        }
    }
예제 #4
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "MainCamera")
     {
         if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))
         {
             Debug.Log("Mirando a eje del engranaje");
             if (coleccionables.engranaje)
             {
                 imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);
                 inventario invent = GameObject.Find("Inventario").GetComponent <inventario>();
                 if (Input.GetMouseButtonDown(0))
                 {
                     if (invent.IsSeleccionado("engranaje"))
                     {
                         engranaje.SetActive(true);
                         coleccionables.SendMessage("ActivaEjeEngranaje");
                         gameObject.SetActive(false);
                         invent.QuitarObjeto("engranaje");
                         imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
                     }
                     else
                     {
                         //TODO decir qeue falta una pieza
                     }
                 }
             }
         }
         else
         {
             imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
         }
     }
 }
예제 #5
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "MainCamera" && coleccionables.carpeta)
     {
         if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))
         {
             Debug.Log("Mirando a mesa");
             imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);
             inventario invent = GameObject.Find("Inventario").GetComponent <inventario>();
             if (Input.GetMouseButtonDown(0) && invent.IsSeleccionado("carpeta"))
             {
                 coleccionables.SendMessage("ActivaDejarCarpeta");
                 carpeta.SetActive(true);
                 monedas.SetActive(true);
                 invent.QuitarObjeto("carpeta");
                 Destroy(gameObject);
                 imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
             }
         }
         else
         {
             imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
         }
     }
 }
예제 #6
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "MainCamera")
     {
         if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))
         {
             Debug.Log("Mirando a puerta del armario del faro");
             if (coleccionables.reloj)
             {
                 imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);
                 inventario invent = GameObject.Find("Inventario").GetComponent <inventario>();
                 if (Input.GetMouseButtonDown(0) && invent.IsSeleccionado("llave"))
                 {
                     coleccionables.SendMessage("ActivaPuertaFaro");
                     eje.SetActive(true);
                     transform.parent.gameObject.SetActive(false);
                     invent.QuitarObjeto("llave");
                     imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
                 }
             }
         }
         else
         {
             imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
         }
     }
 }
예제 #7
0
    void OnTriggerStay(Collider other)
    {
        if (other.tag == "MainCamera")
        {
            if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))
            {
                Debug.Log("Mirando a montón tierra");

                if (coleccionables.pala && coleccionables.linterna)
                {
                    imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);
                    inventario invent = GameObject.Find("Inventario").GetComponent <inventario>();
                    if (Input.GetMouseButtonDown(0))
                    {
                        if (invent.IsSeleccionado("pala"))
                        {
                            //Sonido
                            PlaySound();
                            //Fin sonido

                            transform.parent.gameObject.SetActive(false);
                            engranaje.gameObject.SetActive(true);
                            invent.QuitarObjeto("pala");
                            imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
                        }
                        else
                        {
                        }
                    }
                }
            }
            else
            {
                imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
            }
        }
    }
예제 #8
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "MainCamera" && coleccionables.gema)
     {
         if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))
         {
             Debug.Log("Mirando a Obelisco");
             imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);
             inventario invent = GameObject.Find("Inventario").GetComponent <inventario> ();
             if (Input.GetMouseButtonDown(0) && invent.IsSeleccionado("gema"))
             {
                 coleccionables.SendMessage("ColocaGema");
                 Destroy(gameObject);
                 invent.QuitarObjeto("gema");
                 Debug.Log("TE HAS PASADO EL JUEGO LOKO");
                 imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
             }
         }
         else
         {
             imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
         }
     }
 }
예제 #9
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "MainCamera" && coleccionables.escarabajo)
     {
         if (Physics.Raycast(other.transform.position, other.transform.forward, 3f, objetos))
         {
             Debug.Log("Mirando a Pedestal");
             imagenInteractuar.color = new Color(1f, 1f, 1f, 1f);
             inventario invent = GameObject.Find("Inventario").GetComponent <inventario> ();
             if (Input.GetMouseButtonDown(0) && invent.IsSeleccionado("escarabajo"))
             {
                 invent.QuitarObjeto("escarabajo");
                 coleccionables.SendMessage("ColocaEscarabajo");
                 puerta.SendMessage("Abrir");
                 this.gameObject.SetActive(false);
                 imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
             }
         }
         else
         {
             imagenInteractuar.color = new Color(1f, 1f, 1f, 0f);
         }
     }
 }