예제 #1
0
 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));
     }
 }
예제 #2
0
 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);
             }
         }
     }
 }
예제 #3
0
 public override void enter()
 {
     playerHealthAndShield.damage(damagePerSecond * Time.fixedDeltaTime, healthRatio, shieldRatio);
 }