/// <summary> /// Defines the interaction between this projectile and a target actor /// when they touch. /// </summary> /// <param name="target">The actor that is touching this object.</param> /// <returns>True if the objects meaningfully interacted.</returns> public override bool Touch(Actor target) { // check the target, if we have one if (target != null) { // don't bother hitting any power-ups if (target is PowerUp) { return(false); } // don't hit the owner if the damageOwner flag isn't set if ((target == owner) && (this.damageOwner == false)) { return(false); } // don't hit other projectiles from the same ship Projectile projectile = target as Projectile; if ((projectile != null) && (projectile.Owner == this.Owner)) { return(false); } // damage the target target.Damage(this, this.damageAmount); } // either we hit something or the target is null - in either case, die Die(target); return(base.Touch(target)); }
/// <summary> /// Defines the interaction between this projectile and a target actor /// when they touch. /// </summary> /// <param name="target">The actor that is touching this object.</param> /// <returns>True if the objects meaningfully interacted.</returns> public override bool Touch(Actor target) { // check the target, if we have one if (target != null) { // don't bother hitting any power-ups if (target is PowerUp) { return false; } // don't hit the owner if the damageOwner flag isn't set if ((target == owner) && (this.damageOwner == false)) { return false; } // don't hit other projectiles from the same ship Projectile projectile = target as Projectile; if ((projectile != null) && (projectile.Owner == this.Owner)) { return false; } // damage the target target.Damage(this, this.damageAmount); } // either we hit something or the target is null - in either case, die Die(target); return base.Touch(target); }