public void controlvida(int damage) { if (vida > 0) { vida = vida - damage; CDnodamage = currentCDnodamage; controlanimaciones.SetTrigger("recibir_golpe"); GameObject damaget = Instantiate(damagesufrido, spaun_damage.transform.position, damagesufrido.transform.rotation); damaget.GetComponentInChildren <Text>().text = "-" + damage; damage1.AddForce(new Vector2(0, jumpforce1), ForceMode2D.Impulse); if (this.transform.position == player.transform.position) { damage1.AddForce(new Vector2(-2.5f, jumpforce1), ForceMode2D.Impulse); giro.flipX = false; } if (this.transform.position != player.transform.position) { damage1.AddForce(new Vector2(2.5f, jumpforce1), ForceMode2D.Impulse); giro.flipX = true; } } if (vida <= 0) { Destroy(this.gameObject, 2); controlanimaciones.SetBool("muerto", true); controlanimaciones.SetTrigger("muerte"); player.controlvida(4000); } }
public void OnTriggerStay2D(Collider2D collision) { if (currentCDnodamage <= 0) { if (collision.gameObject.CompareTag("player")) { if (player.ataque1 == true) { controlvida(player.espadazo); } } } if ((player.escudo == false) && (player.currentCDnodamage <= 0)) { if (collision.gameObject.CompareTag("player")) { if (ataque1 == true) { player.controlvida(35); } if (ataque2 == true) { player.controlvida(40); } } } }
public void OnTriggerEnter2D(Collider2D collision) { if ((player.escudo == false) && (player.currentCDnodamage <= 0)) { if (collision.gameObject.CompareTag("player")) { player.controlvida(10); } } if (collision.gameObject.CompareTag("boladefuego")) { Destroy(collision.gameObject); GameObject muerte = Instantiate(muertefuego, spawnfuego.transform.position, muertefuego.transform.rotation); currentCDfuego = CDfuego; if (currentCDfuego <= 0) { Destroy(muerte); Destroy(this.gameObject); } } if (collision.gameObject.CompareTag("corte")) { Destroy(collision.gameObject); Destroy(this.gameObject); } if (collision.gameObject.CompareTag("rayo")) { Destroy(this.gameObject); } }
public void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player")) { print("entrocolision"); if (player.ataque1 == true) { print("detectoataque"); Destroy(this.gameObject, 2); controlanimaciones.SetBool("muerto", true); controlanimaciones.SetTrigger("muerte"); player.controlscore(80); } } if (collision.gameObject.CompareTag("Player")) { if (ataque1 == true) { player.controlvida(15); } } }
public void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.CompareTag("player")) { if (player.ataque1 == true) { Destroy(this.gameObject); } } if ((player.escudo == false) && (player.currentCDnodamage <= 0)) { if (collision.gameObject.CompareTag("player")) { if (ataque1 == true) { player.controlvida(15); } if (ataque2 == true) { player.controlscore(15); } } } }