コード例 #1
0
        /// <summary>
        /// Handles collisions between a bullet and an asteroid.
        /// </summary>
        /// <param name="left">The first object involved in the collision.</param>
        /// <param name="right">The second object involved in the collision.</param>
        /// <param name="point">The point that has been detected inside a hull.</param>
        /// <param name="normal">The normal to the closest surface to the point.</param>
        /// <param name="dist">The distance to the closest surface.</param>
        /// <param name="environment">A reference to the physics engine.</param>
        public override void Collide(Entity left, Entity right, Vector3 point, Vector3 normal, float dist, PhysicsEngine.Environment environment)
        {
            // Increase the score
            Score.AsteroidHit();

            base.Collide(left, right, point, normal, dist, environment);

            // Add an explosion to the list of explosions
            explosions.AddExplosion(left.Position);
            soundBank.PlayCue("explosion2");
        }
コード例 #2
0
        /// <summary>
        /// Handles collisions between the ship and an asteroid.
        /// </summary>
        /// <param name="left">The first object involved in the collision.</param>
        /// <param name="right">The second object involved in the collision.</param>
        /// <param name="point">The point that has been detected inside a hull.</param>
        /// <param name="normal">The normal to the closest surface to the point.</param>
        /// <param name="dist">The distance to the closest surface.</param>
        /// <param name="environment">A reference to the physics engine.</param>
        public override void Collide(Entity left, Entity right, Vector3 point, Vector3 normal, float dist, PhysicsEngine.Environment environment)
        {
            if (ship.IsAlive)
            {
                // Update Score
                Score.asteroidsHit++;
                explosions.AddExplosion(left.Position);
                ship.IsAlive = false;

                // Call the base collision handler
                base.Collide(left, right, point, normal, dist, environment);

                // Play the explosion sound
                soundBank.PlayCue("explosion2");
            }
        }