コード例 #1
0
 public void OnTriggerEnter2D(Collider2D collision)
 {
     if (!collision.CompareTag("Player"))
     {
         if (collision.CompareTag("enemy") || collision.CompareTag("enemy_rt") ||
             collision.CompareTag("enemy_goomba") || collision.CompareTag("boss"))
         {
             IMonster monster = collision.gameObject.GetComponent <IMonster>();
             monster.TakeDamage();
             monster.TakeDamage();
             monster.ObserveHP();
         }
     }
 }
コード例 #2
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.CompareTag("enemy") || coll.gameObject.CompareTag("enemy_rt") ||
         coll.gameObject.CompareTag("enemy_goomba") || coll.gameObject.CompareTag("boss"))
     {
         Destroy(this.transform.parent.gameObject);
         IMonster bt = coll.gameObject.GetComponent <IMonster>();
         bt.TakeDamage();
         bt.ObserveHP();
         Hit(coll.transform.position);
     }
     else if (coll.gameObject.CompareTag("rock"))
     {
         Destroy(this.transform.parent.gameObject);
         Hit(coll.transform.position);
     }
 }