示例#1
0
 public virtual void OnRemove()
 {
     // If scene is in progress
     if (isQuitting == false)
     {
         // Find all colliders in specified radius
         //Collider2D[] cols = Physics2D.OverlapCircleAll(transform.position, radius);
         Collider[] cols = Physics.OverlapSphere(transform.position, radius);
         foreach (Collider col in cols)
         {
             // If target can receive damage
             Targetable damageTaker = col.gameObject.GetComponent <Targetable>();
             if (damageTaker != null)
             {
                 // Target takes damage equal bullet damage * AOE Damage Rate
                 damageTaker.TakeDamage((int)(Mathf.Ceil(aoeDamageRate * (float)bullet.GetDamage())), col.transform.position, alignmentProvider);
             }
         }
         if (explosion != null)
         {
             // Create explosion visual effect
             Destroy(Instantiate <GameObject>(explosion, transform.position, transform.rotation), explosionDuration);
         }
     }
 }
示例#2
0
 /// <summary>
 /// Raises the destroy event.
 /// </summary>
 void OnDestroy()
 {
     // If scene is in progress
     if (isQuitting == false)
     {
         // Find all colliders in specified radius
         Collider2D[] cols = Physics2D.OverlapCircleAll(transform.position, radius);
         foreach (Collider2D col in cols)
         {
             if (IsTagAllowed(col.tag) == true)
             {
                 // If target can receive damage
                 DamageTaker damageTaker = col.gameObject.GetComponent <DamageTaker>();
                 if (damageTaker != null)
                 {
                     // Target takes damage equal bullet damage * AOE Damage Rate
                     damageTaker.TakeDamage((int)(Mathf.Ceil(aoeDamageRate * (float)bullet.GetDamage())));
                 }
             }
         }
         if (explosion != null)
         {
             // Create explosion visual effect
             Destroy(Instantiate <GameObject>(explosion, transform.position, transform.rotation), explosionDuration);
         }
         if (sfx != null && AudioManager.instance != null)
         {
             // Play sfx
             AudioManager.instance.PlaySound(sfx);
         }
     }
 }