Ejemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            PlayerShotManager.Update(gameTime);
            Proton.Update(gameTime);

            if (!Destroyed)
            {
                if (ProtonCannonUp)
                {
                    protonTime += gameTime.ElapsedGameTime.TotalSeconds;

                    if (protonTime >= protonTimeMax)
                    {
                        ProtonCannonUp = false;
                        protonTime     = 0;
                    }
                }
                playerSprite.Velocity = Vector2.Zero;

                shotTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;

                HandleKeyboardInput(Keyboard.GetState());
                HandleGamepadInput(GamePad.GetState(PlayerIndex.One));

                playerSprite.Velocity.Normalize();
                playerSprite.Velocity *= playerSpeed;

                playerSprite.Update(gameTime);
                imposeMovementLimits();
            }
        }
Ejemplo n.º 2
0
 public void Update(GameTime gameTime)
 {
     EnemyShotManager.Update(gameTime);
     for (int x = Enemies.Count - 1; x >= 0; x--)
     {
         Enemies[x].Update(gameTime);
         if (Enemies[x].IsActive() == false)
         {
             Enemies.RemoveAt(x);
         }
         else
         {
             if ((float)rand.Next(0, 1000) / 10 <= shipShotChance)
             {
                 Vector2 fireLoc = Enemies[x].EnemySprite.Location;
                 fireLoc += Enemies[x].gunOffset;
                 Vector2 shotDirection = playerManager.playerSprite.Center - fireLoc;
                 shotDirection.Normalize();
                 EnemyShotManager.FireShot(fireLoc, shotDirection, false);
             }
         }
     }
     if (Active)
     {
         updateWaveSpawns(gameTime);
     }
 }
Ejemplo n.º 3
0
        public void Update(GameTime gameTime)
        {
            PlayerShotManager.Update(gameTime);

            if (!Destroyed)
            {
                playerDirection.Velocity   = Vector2.Zero;
                playerSpriteDown.Location  = playerDirection.Location;
                playerSpriteLeft.Location  = playerDirection.Location;
                playerSpriteUp.Location    = playerDirection.Location;
                playerSpriteRight.Location = playerDirection.Location;


                shotTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;

                HandleKeyboardInput(Keyboard.GetState());
                HandleGamepadInput(GamePad.GetState(PlayerIndex.One));

                playerDirection.Velocity.Normalize();
                playerDirection.Velocity *= playerSpeed;

                playerDirection.Update(gameTime);
                imposeMovementLimits();
            }
        }
Ejemplo n.º 4
0
        public void Update(GameTime gameTime)
        {
            PlayerShotManager.Update(gameTime);

            if (!Destroyed)
            {
                playerSprite.Velocity = Vector2.Zero;

                shotTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;

                if (PowerupOn)
                {
                    PowerupTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (PowerupTimer > PowerupTime)
                    {
                        PowerupTimer = 0;
                        minShotTimer = 0.2f;
                        PowerupOn    = false;
                    }
                }

                HandleKeyboardInput(Keyboard.GetState());
                HandleGamepadInput(GamePad.GetState(PlayerIndex.One));

                playerSprite.Velocity.Normalize();
                playerSprite.Velocity *= playerSpeed;

                playerSprite.Update(gameTime);
                imposeMovementLimits();
            }
        }
Ejemplo n.º 5
0
        public void Update(GameTime gameTime)
        {
            PlayerShotManager.Update(gameTime);

            if (!Destroyed)
            {
                Gunship.Velocity = Vector2.Zero;

                shotTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;

                HandleKeyboardInput(Keyboard.GetState());
                HandleGamepadInput(GamePad.GetState(PlayerIndex.One));

                Gunship.Velocity.Normalize();
                Gunship.Velocity *= playerSpeed;

                Gunship.Update(gameTime);
                imposeMovementLimits();
            }
        }
Ejemplo n.º 6
0
        public void Update(GameTime gameTime)
        {
            PlayerShotManager.Update(gameTime);
            powerUp.Update(gameTime);

            if (!Destroyed)
            {
                if (ShieldsUp)
                {
                    shieldTimer += gameTime.ElapsedGameTime.TotalSeconds;

                    if (shieldTimer >= 10)
                    {
                        ShieldsUp = false;
                        playerSprite.CollisionRadius = playerRadius;
                        shieldTimer = 0;
                    }
                }
                playerSprite.Velocity = Vector2.Zero;

                shotTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;

                HandleKeyboardInput(Keyboard.GetState());
                HandleGamepadInput(GamePad.GetState(PlayerIndex.One));

                playerSprite.Velocity.Normalize();
                playerSprite.Velocity *= playerSpeed;

                playerSprite.Update(gameTime);

                if (playerSprite.IsBoxColliding(powerUp.BoundingBoxRect))
                {
                    ShieldsUp = true;
                    playerSprite.CollisionRadius = playerRadius * 3;
                    powerUp.Location             = new Vector2(rand.Next(40, 720), -400);
                }

                imposeMovementLimits();
            }
        }
Ejemplo n.º 7
0
        public void Update(GameTime gameTime)
        {
            PlayerShotManager.Update(gameTime);
            for (int i = 0; i < 17; i++)
            {
                if (PlayerScore > i * 400)
                {
                    SoundManager.Music[i].Volume = 1f;
                }
            }

            SheildPowerUP.Update(gameTime);
            SheildRemaining--;

            String temp = SheildRemaining.ToString();

            if (SheildRemaining > 10)
            {
                SheildVisible = true;
                int temp2 = Convert.ToInt32(temp.Substring(0, temp.Length - 1));
                Sheildbar.frames[0] = new Rectangle(45, 400, 2, temp2);
                if (SheildRemaining > 230)
                {
                    Sheildbar.TintColor = Color.Green;
                }
                else
                {
                    Sheildbar.TintColor = Color.Red;
                }
            }
            else
            {
                SheildVisible = false;
            }

            if (rand.Next(0, 1000) == 1 && !SheildPowerUP.isVisible && !SheildVisible)
            {
                SheildPowerUP.isVisible = true;
                SheildPowerUP.Location  = new Vector2(rand.Next(0, 800), -50);
                SheildPowerUP.Velocity  = new Vector2(0, 100);
            }
            if (SheildPowerUP.Location.Y > 700)
            {
                SheildPowerUP.Location  = new Vector2(0, 0);
                SheildPowerUP.isVisible = false;
            }
            if (SheildPowerUP.IsCircleColliding(playerSprite.Center, playerSprite.CollisionRadius))
            {
                SheildRemaining         = 460;
                SheildPowerUP.Location  = new Vector2(0, 0);
                SheildPowerUP.isVisible = false;
            }
            if (!Destroyed)
            {
                playerSprite.Velocity = Vector2.Zero;

                shotTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;

                HandleKeyboardInput(Keyboard.GetState());
                HandleGamepadInput(GamePad.GetState(PlayerIndex.One));

                playerSprite.Velocity.Normalize();
                playerSprite.Velocity *= playerSpeed;

                EffectManager.Effect("ShipSmokeTrail").Trigger(new Vector2(playerSprite.Center.X, playerSprite.Center.Y + 10));
                playerSprite.Update(gameTime);
                imposeMovementLimits();
            }
        }