示例#1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Enemy"))
     {
         EnemyHealthBase enemyHealth = other.GetComponent <EnemyHealthBase> ();
         if (enemyHealth != null)
         {
             enemyHealth.Damage(damagePerShot);
         }
         explosionEffect.Play();
         Destroy(gameObject, 0.1f);
     }
     else if (other.CompareTag("LowerCollider"))
     {
         bossHealth = GameObject.FindGameObjectWithTag("Boss").GetComponent <WhipMasterHealth> ();
         bossHealth.Damage(damagePerShot);
         explosionEffect.Play();
         Destroy(gameObject, 0.1f);
     }
     else if (other.CompareTag("UpperCollider"))
     {
         explosionEffect.Play();
         Destroy(gameObject, 0.1f);
     }
     else if (other.CompareTag("BoxTwo"))
     {
         boxHealth = GameObject.FindGameObjectWithTag("BoxTwo").GetComponent <BoxHealth> ();
         boxHealth.Damage(damagePerShot);
         explosionEffect.Play();
         Destroy(gameObject, 0.1f);
     }
 }
示例#2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Enemy"))
     {
         EnemyHealthBase enemyHealth = other.GetComponent <EnemyHealthBase> ();
         if (enemyHealth != null)
         {
             enemyHealth.Damage(damage);
         }
         playerScore.IncreaseScore(250);
     }
     else if (other.CompareTag("LowerCollider") || other.CompareTag("UpperCollider"))
     {
         bossHealth = GameObject.FindGameObjectWithTag("Boss").GetComponent <WhipMasterHealth> ();
         bossHealth.Damage(damage);
         playerScore.IncreaseScore(550);
     }
     else if (other.CompareTag("BoxTwo"))
     {
         boxHealth = GameObject.FindGameObjectWithTag("BoxTwo").GetComponent <BoxHealth> ();
         boxHealth.Damage(damage);
         playerScore.IncreaseScore(50);
     } //if-else
 }     //OnTriggerEnter2D