コード例 #1
0
        public void Update(GraphicsDeviceManager graphics, Sprite enemy, EnemyShots enemyShots)
        {
            if (rand.NextDouble() < 0.01 && enemy.Position.X > -10 && enemy.Position.X < graphics.PreferredBackBufferWidth + 10 && enemy.Name != "Explode")
            {
                enemy.OKFire = true;
                enemy.bulletCount = 0;
            }

            if (enemy.enemyType.type == EnemyType.Etype.Gunner && enemy.OKFire)
            {
                if (enemy.bulletCount < 7)
                {
                    gunnerSound.Play();
                    enemyShots.AddShot(enemy);
                    enemy.bulletCount++;
                }
                else
                {
                    enemy.OKFire = false;
                }
            }
            else if (enemy.enemyType.type == EnemyType.Etype.Level1Boss && enemy.OKFire)
            {
                if (enemy.bulletCount < 2)
                {
                    simpleSound.Play();
                    enemyShots.AddShot(enemy);
                    enemy.bulletCount++;
                }
                else
                {
                    enemy.OKFire = false;
                }
            }
            else if (enemy.OKFire)
            {
                simpleSound.Play();
                enemyShots.AddShot(enemy);
                enemy.OKFire = false;
            }
        }
コード例 #2
0
        public void Update(GamePadState state, Sprite player, Player dino, PlayerShots playerShots, GraphicsDeviceManager graphics, GameTime gameTime, GameState gameState)
        {
            _oldInput = _currentInput;
            _currentInput = state;

            _movement = Vector2.Zero;

            if ((_currentInput.IsButtonUp(Buttons.LeftThumbstickRight)) && player.Position.X > 50)
            {
                _movement -= Vector2.UnitX * .7f;
            }
            if ((_currentInput.IsButtonUp(Buttons.LeftThumbstickLeft)) && player.Position.X < graphics.PreferredBackBufferWidth - 50)
            {
                _movement += Vector2.UnitX * .7f;
            }
            if ((_currentInput.IsButtonUp(Buttons.LeftThumbstickDown)) && player.Position.Y > (graphics.PreferredBackBufferHeight / 2) + 100)
            {
                _movement -= Vector2.UnitY * .5f;
            }
            if ((_currentInput.IsButtonUp(Buttons.LeftThumbstickUp)) && player.Position.Y < graphics.PreferredBackBufferHeight - player.Texture.Height)
            {
                _movement += Vector2.UnitY * .5f;
            }

            // Jamie Key
            if (_currentInput.IsButtonDown(Buttons.Y) && !_oldInput.IsButtonDown(Buttons.Y))
            {
                if (dino._laserPowerLevel < 5)
                    dino._laserPowerLevel += 1;
                else
                    dino._laserPowerLevel = 1;
            }

            if (_currentInput.Buttons.A  == ButtonState.Pressed)
            {
                if (dino.LaserCharge > 0)
                {
                    dino._currentCharge -= 1;

                    if (dino.PlayerIndex == PlayerIndex.One)
                    {
                        playerShots.FireOne(dino);
                    }
                    else if (dino.PlayerIndex == PlayerIndex.Two)
                    {
                        playerShots.FireTwo(dino);
                    }
                }
            }

            if (player.IsInMarsh)
            {
                player.Movement += _movement / 3;
            }
            else
            {
                player.Movement += _movement;
            }
            player.Update(gameTime);
            _movement.X = 0f;
            _movement.Y = 0f;
            player.Movement = _movement;
            player.Update(gameTime);
        }