コード例 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (hitLayers == (hitLayers | (1 << collision.gameObject.layer)))
        {
            Explode(transform.position, transform.rotation);

            DealDamage  dealDamage = gameObject.GetComponent <DealDamage>();
            ITakeDamage takeDamage = collision.gameObject.GetComponent <ITakeDamage>();
            if (dealDamage != null && takeDamage != null)
            {
                takeDamage.SufferDamage(dealDamage.damage);
            }
        }
    }