public override void Update(float elapsedTime) { currentTime += elapsedTime; float t = currentTime / runTime; if (t <= 1.0f) { //Do Bezier logic here var nextPos = ChaosDriveMath.CalculateBezierCurveLocation(controlPoints, t); velocity = nextPos - position; position = nextPos; } else { position += velocity; } UpdateHitEffect(elapsedTime); ActiveSprite.Update(elapsedTime); ActiveSprite.Position = position; if (health <= 0) { shouldRemove = true; } if (currentTime >= runTime && !ActiveSprite.Bounds.Intersects(bounds)) { shouldRemove = true; } }
public override void Update(float elapsedTime) { if (!shouldRemove) { workingTime += elapsedTime; } if (workingTime > pathTimes[activePath]) { workingTime -= pathTimes[activePath]; if (activePath == 0 || activePath == 2) { activePath = 1; } else { activePath = 2; } } float t = workingTime / pathTimes[activePath]; position = ChaosDriveMath.CalculateBezierCurveLocation(paths[activePath], t); UpdateHitEffect(elapsedTime); ActiveSprite.Update(elapsedTime); ActiveSprite.Position = position; if (health <= 0) { shouldRemove = true; } }
public override void Update(float elapsedTime) { activeRunTime += elapsedTime; currentTime += elapsedTime; if (currentCurve < bezierCurves.Count) { float t = activeRunTime / runTimes[currentCurve]; if (t <= 1.0) { var nextPos = ChaosDriveMath.CalculateBezierCurveLocation(bezierCurves[currentCurve], t); velocity = nextPos - position; position = nextPos; } else { activeRunTime -= runTimes[currentCurve]; currentCurve++; if (currentCurve < bezierCurves.Count) { t = activeRunTime / runTimes[currentCurve]; var nextPos = ChaosDriveMath.CalculateBezierCurveLocation(bezierCurves[currentCurve], t); velocity = nextPos - position; position = nextPos; } } } else { position += velocity; } if (bullets.Count > 0) { if (bullets.Any(b => b.LaunchTime < currentTime)) { OnShotsFired(); } } UpdateHitEffect(elapsedTime); ActiveSprite.Update(elapsedTime); ActiveSprite.Position = position; if (health <= 0) { shouldRemove = true; } if (currentCurve >= bezierCurves.Count && activeRunTime >= runTimes.Last() && !ActiveSprite.Bounds.Intersects(bounds)) { shouldRemove = true; } }