private void OnTriggerStay(Collider other) { if (liver == null || liver.IsInvincible) { return; } if (other.CompareTag("HurtEnvironment") || other.CompareTag("HurtPlayer")) { scene.fight = true; Player player = other.GetComponentInParent <Player>(); if (player != null) { player.LandedHit(gameObject); } else { IHurter hurter = other.GetComponent <IHurter>(); if (hurter != null) { hurter.LandedHit(gameObject); } } animator.SetInteger("State", 2); liver.TakeDamage(1); Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity); Vector3 direction = other.transform.position - transform.position; direction.Normalize(); } }
private void OnTriggerStay(Collider other) { if (liver == null || liver.IsInvincible) { return; } if (other.CompareTag("HurtEnvironment") || other.CompareTag("HurtPlayer")) { Player player = other.GetComponentInParent <Player>(); if (player != null) { player.LandedHit(gameObject); } else { IHurter hurter = other.GetComponent <IHurter>(); if (hurter != null) { hurter.LandedHit(gameObject); } } ChangeState(FlyingHeadState.Hurt); liver.TakeDamage(1); Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity); Vector3 direction = other.transform.position - transform.position; direction.y = 0; direction.Normalize(); rigidbody.AddForce(-direction * 450); if (healthUi != null) { healthUi.SetActive(true); if (healthUiTimer != null) { Destroy(healthUiTimer.gameObject); } healthUiTimer = Timer.Create(1f, () => { if (healthUi != null) { healthUi.SetActive(false); } }); } } }
public void TakeDamage(int damage = 1, GameObject other = null) { if (IsInvincible) { return; } Health -= damage; IsInvincible = true; invincibilityTime = InvincibilityDuration; Sounds.Play("Hit"); if (other) { IHurter hurter = other.GetComponent <IHurter>(); if (hurter != null) { hurter.LandedHit(gameObject); } } }