protected override void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.GetComponent <TongueJoint>())
        {
            return;
        }
        if (col.gameObject.GetComponent <ProjectileController>())
        {
            return;
        }

        //if (vehicle.isColliding.Contains(col.gameObject)) return;
        //vehicle.isColliding.Add(col.gameObject);

        AffectVisitor   damager   = col.gameObject.GetComponent <AffectVisitor>();
        AffectVisitable damagable = gameObject.GetComponent <AffectVisitable>();

        if (damager == null)
        {
            //Debug.LogWarning("Non-damager " + col.gameObject.name + " collided with damageable " + gameObject.name + ", please implement AffectVisitor method on it, or exclude from check on this damagable. ");
            return;
        }

        damagable.AcceptAffectFrom(damager);
    }
Example #2
0
    void ReceiveDamage(Collision2D col)
    {
        if (!col.gameObject.GetComponent <ProjectileController>())
        {
            return;
        }

        AffectVisitor   damager   = col.gameObject.GetComponent <AffectVisitor>();
        AffectVisitable damagable = gameObject.GetComponent <AffectVisitable>();

        damagable.AcceptAffectFrom(damager);
    }
    protected override void OnCollisionEnter2D(Collision2D col)
    {
        if (!col.gameObject.GetComponent <ProjectileController>())
        {
            return;
        }

        AffectVisitor   damager   = col.gameObject.GetComponent <AffectVisitor>();
        AffectVisitable damagable = gameObject.GetComponent <AffectVisitable>();

        damagable.AcceptAffectFrom(damager);
    }