void OnCollisionEnter2D(Collision2D col) { //si es que el enemigo ejecuta daño a Joe a este se le reducira la vida if (col.gameObject.tag == "Enemy" || col.gameObject.tag == "EnemigoVolador" && vidajoe > 0) { enemigo = col.gameObject; scriptenemigo = enemigo.GetComponent <Enemigo>(); au.clip = efectos[0]; au.Play(); anim.SetTrigger("daño"); Physics2D.IgnoreLayerCollision(0, 0); sprite.color = new Color(1f, 1f, 1f, .5f); if (sprite.flipX == false) { rigid.AddForce(new Vector2(-16f, 6f), ForceMode2D.Impulse); } else { rigid.AddForce(new Vector2(16f, 6f), ForceMode2D.Impulse); } if (scriptenemigo != null) { vidajoe -= scriptenemigo.getdaño(); } } //la barra de vida será reducida según el daño if (col.gameObject.tag == "Barrera" && vidajoe > 0) { barrera = col.gameObject; barreramuerte = barrera.GetComponent <Barrera>(); vidajoe -= barreramuerte.getdaño(); } if (col.gameObject.name == "Proyectil(Clone)") { GameObject proyectil = col.gameObject; Proyectil scriptproyectil = proyectil.GetComponent <Proyectil>(); vidajoe -= scriptproyectil.getdaño(); } if (col.gameObject.name == "Hueso") { GameObject proyectil = col.gameObject; VidaJefeFinal script = proyectil.GetComponentInParent <VidaJefeFinal>(); vidajoe -= script.getDañoHueso(); } }
void Awake() { Time.timeScale = 1; scriptvida = GetComponent <VidaJefeFinal>(); anim = GetComponent <Animator>(); rigid = GetComponent <Rigidbody2D>(); inicio = rigid.position; foreach (float distancias in distancias) { posicionesfin.Add(inicio + new Vector2(-distancias, 0f)); } estado = estados.haciafinal; }