Example #1
0
    /**
     * @brief
     * sprawdzanie kolizji komu ma zadac obrazenia i kiedy ma sie zniszczyc a kiedy ma pominc kolizje
     */
    protected void OnTriggerEnter2D(Collider2D collision)
    {
        IGetDamaged target = collision.GetComponent <IGetDamaged>();

        if (collision.gameObject.tag == "Bullet")
        {
            return;
        }

        if (collision.gameObject.tag == "Gun")
        {
            return;
        }

        if (collision.gameObject.tag == "Surface")
        {
            return;
        }

        if (target != null)
        {
            target.GetDamage(damage);
        }

        Destroy(gameObject);

        //IBulletDestroyable detory = collision.GetComponent<IBulletDestroyable>();

        //if (collision.GetComponent<IBulletDestroyable>() != null)
        //{
        //    Destroy(gameObject);
        //}
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IGetDamaged target = collision.GetComponent <IGetDamaged>();

        if (target != null)
        {
            target.GetDamage(damage);
        }
    }
Example #3
0
    protected void OnTriggerEnter2D(Collider2D collision)
    {
        IGetDamaged target = collision.GetComponent <IGetDamaged>();

        if (collision.gameObject.tag == "Wall")
        {
            //Physics2D.IgnoreCollision(collision.gameObject.GetComponent<Collider2D>(), GetComponent<TilemapCollider2D>());
            return;
        }

        if (collision.gameObject.tag == "Square")
        {
            return;
        }

        if (collision.gameObject.tag == "Triangle")
        {
            return;
        }

        if (collision.gameObject.tag == "Ciercle")
        {
            return;
        }

        if (collision.gameObject.tag == "Enemy")
        {
            return;
        }

        if (collision.gameObject.tag == "Gun")
        {
            return;
        }

        if (collision.gameObject.tag == "EnemyBullet")
        {
            return;
        }

        if (collision.gameObject.tag == "Surface")
        {
            return;
        }

        if (target != null)
        {
            target.GetDamage(damage);
        }

        Destroy(gameObject);
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Bullet" || collision.gameObject.tag == "EnemyBullet" || collision.gameObject.tag == "Triangle")
        {
            return;
        }

        IGetDamaged target = collision.GetComponent <IGetDamaged>();

        if (target != null)
        {
            target.GetDamage(10000);
        }
    }
Example #5
0
    void OnParticleCollision(GameObject other)
    {
        IGetDamaged target = other.GetComponent <IGetDamaged>();

        if (target != null)
        {
            target.GetDamage(damage);
        }

        //int collCount = PSystem.GetSafeCollisionEventSize();

        //int eventCount = PSystem.GetCollisionEvents(other, CollisionEvents);

        //for (int i = 0; i < eventCount; i++)
        //{
        //    //TODO: Do your collision stuff here.
        //    // You can access the CollisionEvent[i] to obtaion point of intersection, normals that kind of thing
        //    // You can simply use "other" GameObject to access it's rigidbody to apply force, or check if it implements a class that takes damage or whatever
        //}
    }