Your project manager does not want the UFOs to explode when they crash. He wants you to use the physics simulator to make them rotate and bounce when they collide.
Now, we are going to take advantage of the physics engine's collision detection capabilities:
1. Stay in the
3DInvadersSilverlight
project.2. Open
Ufo.cs
.3. Add the following
public static
constant to identify the kind of 3D character related to a geometry:public static string Tag = "UFO";
4. Add the following
private
method to check the geometry that collides with the Ufo's instance:private bool OnCollision(Geom geom1, Geom geom2, ContactList contactList) { if ((((string) geom1.Tag) == Tag) && (((string) geom2.Tag) == Tag)) // Both geometries represent an UFO return true; else return false; }
5. Replace the line that assigns a width value in the constructor with the following one. (We must be more accurate because we want them to respond to a collision.):
Width...