示例#1
0
    public virtual void ApplyDamage()
    {
        for (int i = 0; i < _intersectingColliders.Count; i++)
        {
            Collider c = _intersectingColliders[i];
            if (!c)
            {
                _intersectingColliders.Remove(c);
                i--;
            }
            else
            {
                DamageReciever dr = c.GetComponent <DamageReciever>();
                if (dr)
                {
                    if (_damageRecipient)
                    {
                        if (_damageRecipient == c.gameObject)
                        {
                            dr.TakeDamageFrom(this);
                        }
                    }
                    else
                    {
                        dr.TakeDamageFrom(this);
                    }
                }
            }
        }

        SetFreezePosition(false);
        currentlyAttacking = false;
    }
示例#2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject == de.owner)
        {
            return;
        }

        DamageReciever dr = collision.gameObject.GetComponent <DamageReciever>();

        if (dr)
        {
            dr.TakeDamageFrom(de);
        }

        Destroy(gameObject);
    }