Ejemplo n.º 1
0
    private void update_damageScan(Vector2 inVelocityDiraction, float inFrameSpeed)
    {
        Vector2 thePosition = transform.position;

        RaycastHit2D theHit = XCollisions2D.raycast(
            thePosition, inVelocityDiraction, inFrameSpeed,
            (Collider2D inCollider) =>
        {
            //TODO: Additional ignore allies
            if (!_instigator)
            {
                return(false);
            }
            return(XUtils.isComponentRelatedToObject(_instigator, inCollider));
        });

        if (!theHit.collider)
        {
            return;
        }

        Damage theDamage = new Damage();

        theDamage.damageAmount = _damageAmount;
        Damage.applyDamage(theHit.collider, theDamage);

        Destroy(gameObject);
    }