Time for action – player shots versus aliens
To implement how the player shots hit an alien craft, perform the following steps:
1. Add the
CrashSaucer()
method to theEnemySaucer
class as follows:#region HelperMethods public void CrashSaucer() { curvePoints[1] = Position; curvePoints[2].Y = -80; curvePoints[2].Z = 0; curveProgress = 0.0f; curveDelta = 0.5f; pitch = MathHelper.ToRadians(20); roll = MathHelper.ToRadians(-20); IsDestroyed = true; } #endregion
2. Add the
Collision Detection
region to theShotManager
class as follows:#region Collision Detection public bool CheckPlayerShotHits(BoundingBox target) { foreach (PlayerShot shot in playerShots) { if (shot.IsActive) { if (target.Intersects(shot.Bounds)) { return true; } } } return false; } #endregion
3. In the
Update()
method of theMarsRunnerPlayScreen
class, add the following code just aftershotManager
has been...