Esempio n. 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);
        }
Esempio n. 2
0
        protected void HitPlayer2(TimeSpan gameTime, int damage)
        {
            SpacewarGame.Players[1].Health -= damage;
            if (SpacewarGame.Players[1].Health <= 0)
            {
                SpacewarGame.Players[1].Health = 5;
                if (SpacewarGame.GameState == GameState.PlayEvolved)
                {
                    particles.AddExplosion(ship2.Position);
                }

                player1Score++;
                Sound.PlayCue(Sounds.ExplodeShip);

                resetShips(gameTime);
            }
            else
            {
                Sound.PlayCue(Sounds.DamageShip);
            }
        }