예제 #1
0
        public void Update(GameTime gameTime)
        {
            if (!Destroyed)
            {
                PlayerShotManager.Update(gameTime);
                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();
            }
        }
예제 #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);
            }
        }