Example #1
0
        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);
        }
Example #2
0
        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;
            }
        }