Time for action – flying the saucer
In order to give the saucer a more realistic flight path, perform the following steps:
1. Add a new
Fields
region to theEnemySaucer
class, containing the following items:#region Fields private Random rand = new Random(); private int flybyChance = 2; private float minflyByDelay = 5f; private float flyByTimer = 0f; private float curveProgress = 0.0f; private float curveDelta = 0.2f; private Vector3[] curvePoints = new Vector3[4]; public bool IsOnScreen = false; public bool IsDestroyed = false; #endregion
2. Add the
Spline Helper Methods
region and its two methods to theEnemySaucer
class as follows:#region Spline Helper Methods public void GenerateNewCurve() { curvePoints[0] = new Vector3(-60, (rand.Next(0, 3) - 1) * 25, 64); curvePoints[1] = new Vector3(-45, rand.Next(12, 19), 64); curvePoints[2] = new Vector3(45, rand.Next(12, 19), 64); curvePoints[3] = new Vector3(60, (rand.Next(0, 3) - 1 * 25), 64); if (rand.Next(0, 2) == 0) { Vector3...