public override void Update(GameTime gameTime) { base.Update(gameTime); if (ParentShip.RigidBody.LinearVelocity.LengthSquared() > 1) { if (soundEffectInstance == null || soundEffectInstance.State == SoundState.Stopped) { soundEffectInstance = EngineSoundEffect.CreateInstance(); soundEffectInstance.Volume = Options.SFXVolume; soundEffectInstance.Play(); } } else { if (soundEffectInstance != null) { soundEffectInstance.Stop(); } soundEffectInstance = null; } EngineBlaze.Update(gameTime); }
public override void Initialize() { base.Initialize(); EngineBlaze = new EngineBlaze(ParentShip, new Vector2(0, 35), new Vector2(25, 70), "Sprites\\GameObjects\\FX\\EngineBlaze", 8, 1, 0.1f, false, true, this); EngineBlaze.LoadContent(); EngineBlaze.Initialize(); }
public override void Draw(SpriteBatch spriteBatch) { if (Visible) { EngineBlaze.Draw(spriteBatch); } base.Draw(spriteBatch); }
public override void Update(GameTime gameTime) { base.Update(gameTime); currentLifeTimer += gameTime.ElapsedGameTime; if (currentLifeTimer >= TimeSpan.FromSeconds(MissileData.BulletLifeTime)) { Die(); } if (RigidBody.LinearVelocity.X < 0) { RigidBody.LinearAcceleration = new Vector2(500, RigidBody.LinearAcceleration.Y); } else { RigidBody.LinearVelocity = new Vector2(0, RigidBody.LinearVelocity.Y); RigidBody.LinearAcceleration = new Vector2(0, RigidBody.LinearAcceleration.Y); } if (Target != null && Target.Alive) { float angle = Trigonometry.GetAngleOfLineBetweenObjectAndTarget(this, Target.WorldPosition); if (Math.Abs(angle - WorldRotation) > 0.1f) { RigidBody.AngularVelocity = 15 * Trigonometry.GetRotateDirectionForShortestRotation(this, Target.WorldPosition); } else { // Bad that we are assuming it is not parented to anything, but I think that is a valid assumption LocalRotation = angle; RigidBody.FullAngularStop(); } } else { RigidBody.FullAngularStop(); } EngineBlaze.Update(gameTime); if (Explosion.Animation.IsPlaying) { Explosion.Update(gameTime); } if (Explosion.Animation.Finished) { Alive = false; } }
public override void Draw(SpriteBatch spriteBatch) { if (Visible) { EngineBlaze.Draw(spriteBatch); } if (Explosion.Animation.IsPlaying) { Explosion.Draw(spriteBatch); } base.Draw(spriteBatch); }
public override void Initialize() { base.Initialize(); RigidBody.MaxLinearVelocity = new Vector2(RigidBody.MaxLinearVelocity.X, MissileData.MaxSpeed); // If the acceleration is non-zero, we change the acceleration of the bullet. Otherwise, we set the bullet's T velocity Y component to be it's max value if (MissileData.LinearAcceleration != 0) { RigidBody.LinearAcceleration = Vector2.Add(Vector2.Zero, new Vector2(0, MissileData.LinearAcceleration)); } else { RigidBody.LinearVelocity = Vector2.Add(Vector2.Zero, new Vector2(0, MissileData.MaxSpeed)); } EngineBlaze = new EngineBlaze(this, new Vector2(0, 1.5f * Size.Y), new Vector2(Size.X, 2 * Size.Y), "Sprites\\GameObjects\\FX\\EngineBlaze", 8, 1, 0.1f, false, true, this); EngineBlaze.LoadContent(); EngineBlaze.Initialize(); Explosion = new Explosion(Vector2.Zero, new Vector2(20, 20), "Sprites\\GameObjects\\FX\\Explosion", 4, 4, 0.025f); Explosion.LoadContent(); Explosion.Initialize(); }