IEnumerator Damage() { while (true) { Collider[] colliders = Physics.OverlapSphere(transform.position, range); foreach (Collider col in colliders) { if (col.CompareTag("Player") || col.CompareTag("Enemy") || col.CompareTag("Destroyable")) { HealthAndShield VictimHealth = col.gameObject.GetComponent <HealthAndShield>(); float distance = Vector3.Distance(col.gameObject.transform.position, transform.position); if (distance < range) { VictimHealth.damage(damagePerClick, grenadeHealthDamageRatio, grenadeShieldDamageRatio); } } } yield return(new WaitForSeconds(ClickInterval)); } }
void GrenadeDamage() { Collider [] colliders = Physics.OverlapSphere(transform.position, range); foreach (Collider col in colliders) { Rigidbody victimRB = col.gameObject.GetComponent <Rigidbody> (); if (victimRB != null && victimRB.gameObject != gameObject) { Force(victimRB); } if (col.CompareTag("Player") || col.CompareTag("Enemy") || col.CompareTag("Destroyable")) { HealthAndShield VictimHealth = col.gameObject.GetComponent <HealthAndShield>(); float distance = Vector3.Distance(col.gameObject.transform.position, transform.position); if (distance < range) { VictimHealth.damage(damage - (distance / range) * damage, grenadeHealthDamageRatio, grenadeShieldDamageRatio); } } } }
public override void enter() { playerHealthAndShield.damage(damagePerSecond * Time.fixedDeltaTime, healthRatio, shieldRatio); }