void OnTriggerEnter2D(Collider2D collider) { HeroRabbit rabbit = collider.GetComponent <HeroRabbit>(); if (rabbit != null) { if (rabbit.isBig) { rabbit.DecreaseRabbitSize(); } LevelController.current.onRabitDeath(rabbit); } }
void OnTriggerEnter2D(Collider2D collider) { HeroRabbit rabbit = collider.GetComponent <HeroRabbit>(); if (rabbit.invulnerableTime <= 0) { if (rabbit.isBig) { rabbit.DecreaseRabbitSize(); rabbit.invulnerableTime = 4; } else { rabbit.isAlive = false; } } }
protected override void OnRabbitHit(HeroRabbit rabbit) { if (rabbit.invulnerableTime <= 0) { if (rabbit.isBig) { rabbit.DecreaseRabbitSize(); rabbit.invulnerableTime = 4; } else { rabbit.isAlive = false; } this.CollectedHide(); } }
void OnTriggerEnter2D(Collider2D collider) { HeroRabbit rabbit = collider.GetComponent <HeroRabbit>(); if (rabbit != null) { // angle check Vector3 dir = collider.transform.position - transform.position; dir = collider.transform.InverseTransformDirection(dir); float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; if (angle < 60 || angle > 120) { if (rabbit.invulnerableTime <= 0) { if (rabbit.isBig) { animator.SetTrigger("attack"); rabbit.DecreaseRabbitSize(); rabbit.invulnerableTime = 4; } else { animator.SetTrigger("attack"); rabbit.isAlive = false; } } } else { // orc dies animator.SetTrigger("die"); isAlive = false; rabbit.TossRabbitUp(); StartCoroutine(dieLater()); } } }