Пример #1
0
    void Golpeado(float direction)
    {
        if (direction == 0)
        {
            direction = 1;
        }

        force.x = -3900f * direction;
        force.y = 0;
        rgb.AddForce(force);
        aSource.PlayOneShot(audio_herida);

        rend.color = new Color(80, 0, 0);
        Invoke("Restore", 0.7f);
        if (life <= 0)
        {
            life = 0;
            anim.SetTrigger("morir");

            /*Analytics.CustomEvent ("GameOver", new Dictionary<string, object> {
             *      {"levels", Statics.level},
             *      {"tries", Statics.tries}
             * });*/
            /*print("evento: "+GetComponent<AnalyticsTracker> ().eventName);
             *
             * GetComponent<AnalyticsTracker> ().TriggerEvent ();*/
            Statics.script.boton_reinicio.gameObject.SetActive(true);
        }
        canva.UpdateLife(life);
        jumping = false;
    }
Пример #2
0
 //Código a ejecutar después de ser atacado
 public void Atacado(float fuerza, GameObject ataco)
 {
     if (!atacante && life > 0)
     {
         atacante = ataco;
         CambioVida(Mathf.Min(fuerza, life) * -1);
         if (life <= 0)
         {
             rgb.velocity = new Vector2(0, 0);
             anim.SetTrigger("morir");
             audio_source.PlayOneShot(audio_die);
             rgb.Sleep();
             foreach (Collider2D coll in colliders)
             {
                 coll.enabled = false;
             }
             Invoke("morir", die_time);
         }
         canva.UpdateLife(life);
         rend.color = new Color(80, 0, 0);
         Invoke("Restore", 0.2f);
         atacante.GetComponent <Bala_Script>().AtaqueRecibido(this);
     }
 }