Ejemplo n.º 1
0
    void OnMouseDown()
    {
        GameObject temp;
        Vector3    pos = this.transform.position;

        pos.y = pos.y + 0.3f;
        //pos.x = pos.x + 0.25f;
        temp = (GameObject)Instantiate(torre1, pos, Quaternion.identity);
        temp.transform.position = pos;
        temp.layer = 5;
        hud        = HudG.GetInstance();
        torre      = temp.GetComponentInChildren <Torre>();


        if (torre.Valor_actual1 < hud.Contador_monedas)
        {
            torre.Esta_viva = false;
            Destroy(this.gameObject);
            hud.DescontarSaldo(torre.Valor_actual1);
        }
        else
        {
            Destroy(temp);
            hud.ErrorSaldo();
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D otro)
    {
        Bala bala;

        if (vidas > 0)
        {
            if (otro.gameObject.tag == "Bala")
            {
                bala           = otro.gameObject.GetComponent <Bala>();
                bala.Disparada = false;
                if (--vidas == 0)
                {
                    esta_viva = false;

                    Debug.Log("Se murio la unidad");
                    hud.Contarmuertes();
                    // cont.Contarmuertes(1);
                    hud = HudG.GetInstance();
                    Instantiate(efecto_postmorten, this.transform.position, Quaternion.identity);
                    Destroy(this.gameObject);

                    hud.ActualizaMonedas(valor_muerte);
                }
                else
                {
                    lb.ModificarBarra(delta_de_vida);
                }
            }
        }
    }
Ejemplo n.º 3
0
 private void Start()
 {
     contador_muertes = 0;
     sonido           = this.GetComponent <AudioSource>();
     modo_ejecucion   = CONSTRUCCION;
     contador_monedas = 300;
     contador_vidas   = 25;
     instancia        = this;
     muerte.enabled   = false;
     victoria.enabled = false;
 }
Ejemplo n.º 4
0
    public void OnPointerClick(PointerEventData eventData)
    {
        HudG hud;

        hud = HudG.GetInstance();
        if (habilitado)
        {
            hud.Modo_ejecucion = HudG.EJECUCION;
            batalla.Play();
            //Debug.Log("click");
            habilitado = false;
        }
    }
Ejemplo n.º 5
0
    private void OnMouseDown()
    {
        hud = HudG.GetInstance();

        if (Valormejora < hud.Contador_monedas)
        {
            estados.SetInteger("Nivel", 1);
            Instantiate(mejora, this.transform.position, Quaternion.identity);
            ct.CambiarEstadoBotones(false);
            child.SetActive(true);
            hud.DescontarSaldo(Valormejora);
        }
        else
        {
            hud.ErrorSaldo();
        }
    }
Ejemplo n.º 6
0
    // Update is called once per frame


    void Update()
    {
        hud = HudG.GetInstance();
        if (EsActualizable())
        {
            if (esta_viva == true)
            {
                // Vector3 dir;
                // dir = posicion_siguiente - this.transform.position;
                //dir.z = 0;
                transform.position = Vector2.MoveTowards(transform.position, posicion_siguiente.position, vel * Time.deltaTime);
                //this.transform.position += dir * vel * Time.deltaTime;
                if (Vector2.Distance(transform.position, posicion_siguiente.position) < distancia_punto)
                {
                    if (indice + 1 < ruta.transform.childCount)
                    {
                        indice++;
                        posicion_actual    = posicion_siguiente;
                        posicion_siguiente = ruta.transform.GetChild(indice);
                        //CambiarPosicion();
                    }
                    else
                    {
                        indice             = 0;
                        transform.position = posicion_inicial;
                        posicion_siguiente = ruta.transform.GetChild(0);
                        posicion_actual    = null;
                        hud.Descontarvidas();
                    }
                }
            }
            else
            {
                Posicion_muerte         = this.transform.position;
                this.transform.position = posicion_inicial;
            }
        }
    }