コード例 #1
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject == owner)
        {
            return;
        }

        IDamagable applyDamage = collision.gameObject.GetComponent <IDamagable>();

        if (applyDamage != null)
        {
            applyDamage.Damage(damage);
            if (debuffs != null)
            {
                //applyDamage.AddDebuff(debuffs());
                foreach (AttackDebuffs debuff in debuffs.GetInvocationList())
                {
                    Debuff d = debuff();
                    applyDamage.AddDebuff(d);
                    Debug.Log($"Added Debuff {d}");
                }
            }
        }
        ContactPoint hit = collision.GetContact(0);

        Instantiate(ImpactEffect, hit.point, Quaternion.LookRotation(hit.normal));

        if (maxBounces > 0)
        {
            maxBounces--;
            Vector3 newDirection = Vector3.Reflect(currentVelocity, hit.normal);
            rbody.AddForce(newDirection, ForceMode.Impulse);
        }
    }