Пример #1
0
        /// <summary>
        /// Defines the interaction between this projectile and a target GameplayObject
        /// when they touch.
        /// </summary>
        /// <param name="target">The GameplayObject that is touching this one.</param>
        /// <returns>True if the objects meaningfully interacted.</returns>
        public bool Touch(GameObject 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 ((this.damageOwner == false) && (target == owner))
                {
                    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, false);

            return base.Touch(target);
        }
Пример #2
0
        /// <summary>
        /// Kills this projectile, in response to the given GameplayObject.
        /// </summary>
        /// <param name="source">The GameplayObject responsible for the kill.</param>
        /// <param name="cleanupOnly">
        /// If true, the object dies without any further effects.
        /// </param>
        public void Die(GameObject source, bool cleanupOnly)
        {
            if (active)
            {
                if (!cleanupOnly)
                {
                    CollisionManager.Explode(this, source, damageAmount, Position,
                        damageRadius, damageOwner);
                }
            }

            base.Die(source, cleanupOnly);
        }