public override void Update(GameTime gametime)
{
switch (projectileState)
{
case PROJECTILE_STATE.STILL:
this.Visible = false;
explosion.Visible = false;
break;
// Using Lerp here could use target - pos and normalise for direction and then apply
// Velocity
case PROJECTILE_STATE.FIRING:
this.Visible = true;
Tileposition = Vector2.Lerp(Tileposition, Target, 0.02f * RocketVelocity);
// rotate towards the Target
this.angleOfRotation = TurnToFace(PixelPosition,
Target, angleOfRotation, 1f);
if (Vector2.Distance(Tileposition, Target) < 0.01f)
projectileState = PROJECTILE_STATE.EXPOLODING;
break;
case PROJECTILE_STATE.EXPOLODING:
explosion.Tileposition = Target;
explosion.Visible = true;
break;
}
// if the explosion is visible then just play the animation and count the timer
if (explosion.Visible)
{
explosion.Update(gametime);
ExplosionTimer += gametime.ElapsedGameTime.Milliseconds;
}
// if the timer goes off the explosion is finished
if (ExplosionTimer > ExplosionVisibleLimit)
{
explosion.Visible = false;
ExplosionTimer = 0;
projectileState = PROJECTILE_STATE.STILL;
}
base.Update(gametime);
}