Example #1
0
        /// <summary>
        /// Updates the bullet. Removes it from scene when item is timed out
        /// </summary>
        /// <param name="time">Current game time</param>
        /// <param name="elapsedTime">Elapsed time since last update</param>
        public override void Update(TimeSpan time, TimeSpan elapsedTime)
        {
            //See if this bullets lifespan has expired
            if (time.TotalSeconds > endTime)
            {
                //BFG explodes and has a blast radius
                if (SpacewarGame.GameState == GameState.PlayEvolved && projectileType == 4 && !exploded)
                {
                    Sound.PlayCue(Sounds.Explosion);
                    particles.AddExplosion(Position);

                    //We don't delete it this frame but we change the radius and the damage
                    exploded = true;
                    radius   = 30;
                    damage   = 3;
                }
                else
                {
                    DeleteProjectile();
                }
            }

            acceleration = thrust;

            //For the rocket we need particles
            if (projectileType == 3)
            {
                particles.AddRocketTrail(shape.World, new Vector2(acceleration.X, -acceleration.Y));
            }

            base.Update(time, elapsedTime);
        }