Пример #1
0
        /// <summary>
        /// Defines the interaction between the oxygen 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)
        {
            // if the oxygen has touched a player, then damage it
            NanoBot player = target as NanoBot;

            if (player != null)
            {
                // calculate damage as a function of how much the two actor's
                // velocities were going towards one another
                Vector2 playerAsteroidVector =
                    Vector2.Normalize(this.position - player.Position);
                float rammingSpeed =
                    Vector2.Dot(playerAsteroidVector, player.Velocity) -
                    Vector2.Dot(playerAsteroidVector, this.velocity);

                if (player.positiveCharge == true)
                {
                    player.Damage(this, this.mass * rammingSpeed * damageScalar * 2f);
                }
                else if (player.negativeCharge != true &&
                         player.positiveCharge != true)
                {
                    player.Damage(this, this.mass * rammingSpeed * damageScalar);
                }

                return(base.Touch(target));
            }
            if ((target is AtomicMoleBlastProjectile) == true)
            {
                target.Die(target);
                this.Die(this);
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             this.direction, 36, 64f * world.ResVar, 128f * world.ResVar,
                                                             2f * world.ResVar, 0.05f * world.ResVar, world.CFC2Color));

                return(base.Touch(target));
            }
            if ((target is Ozone) == true)
            {
                target.Die(target);
                Vector2 newPosition  = (target.Position + this.position) / 2;
                Vector2 newVelocity  = (target.Velocity + this.velocity) / 2;
                Vector2 newDirection = (target.Direction + this.direction) / 2;
                world.UnbondOzone(newPosition, newVelocity, newDirection);
                world.ParticleSystems.Add(new ParticleSystem(target.Position,
                                                             target.Direction, 36, 64f * world.ResVar, 128f * world.ResVar,
                                                             2f * world.ResVar, 0.05f * world.ResVar, world.O3Color));
                this.world.AudioManager.PlayCue("asteroidTouch");

                return(base.Touch(target));
            }
            return(false);
        }
Пример #2
0
        /// <summary>
        /// Defines the interaction between the oxygen 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)
        {
            // if the oxygen has touched a player, then damage it
            NanoBot player = target as NanoBot;

            if (player != null)
            {
                // calculate damage as a function of how much the two actor's
                // velocities were going towards one another
                Vector2 playerAsteroidVector =
                    Vector2.Normalize(this.position - player.Position);
                float rammingSpeed =
                    Vector2.Dot(playerAsteroidVector, player.Velocity) -
                    Vector2.Dot(playerAsteroidVector, this.velocity);

                if (player.negativeCharge == false)
                {
                    player.Damage(this, this.mass * rammingSpeed * damageScalar);
                }

                return(base.Touch(target));
            }
            if ((target is South) == true ||
                (target is Five) == true)
            {
                return(base.Touch(target));
            }
            return(false);
        }