private void OnTriggerStay(Collider collision) { ActorStats stats = collision.gameObject.GetComponent <ActorStats>(); if (stats != null) { stats.TakeDamage(damage); } }
public void OnHit(GameObject attacker, float damage) { stats.TakeDamage(damage); if (stats.Health <= 0) { var destructibles = gameObject.GetComponents(typeof(IDestructible)); foreach (IDestructible d in destructibles) { d.OnDestruction(attacker); } } }
private void OnTriggerEnter(Collider other) { ActorStats stats = other.gameObject.GetComponent <ActorStats>(); if (stats != null) { if (stats.Health == stats.MaxHealth) { return; } stats.TakeDamage(-healthToHeal); AudioManager.Instance.PlaySoundEffect(SoundEffect.Pickup); Destroy(gameObject); } }