Exemplo n.º 1
0
 public void GetHurt(PlayerBullets bullets, Player player)
 {
     foreach (var item in enemies)
     {
         item.HP -= player.DamageDealt(bullets, item);
     }
 }
Exemplo n.º 2
0
 public void Initialize(ContentManager Content, GraphicsDevice graphicsDevice)
 {
     startMenu     = new StartMenu(Content);
     gameOver      = new GameOver(Content);
     playerBullets = new PlayerBullets();
     Bullets       = new Bullets();
     HpBar         = new HpBar();
     Player.Initialize();
     HpBar.Initialize(Player, graphicsDevice);
     Background.Initialize(this.Resolution);
     Font = Content.Load <SpriteFont>("Font1");
 }
Exemplo n.º 3
0
 private void Shoot(KeyboardState oldstate, KeyboardState newState, PlayerBullets playerBullets, ContentManager content)
 {
     if (newState.IsKeyDown(Keys.LeftControl))
     {
         if (!oldState.IsKeyDown(Keys.LeftControl))
         {
             if (playerBonusShoot == PlayerBonusShoot.five)
             {
                 playerBullets.InitializeFiveBulletsShoot(this, content);
             }
             else if (playerBonusShoot == PlayerBonusShoot.three)
             {
                 playerBullets.InitializeThreeBulletsShoot(this, content);
             }
             else
             {
                 playerBullets.InitializeOneBulletShoot(this, content);
             }
         }
     }
 }
Exemplo n.º 4
0
        public void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, PlayerBullets playerBullets,
                           ContentManager content, Enemies enemies, Bullets bullets)
        {
            playerAnimation.Update(gameTime);
            GetHurt(enemies, bullets);
            KeyboardState newState = Keyboard.GetState();

            SetPlayerDirection(oldState, newState);
            PlayerJump(oldState, newState, gameWindow, platforms, shift);
            SetVelocity(gameWindow, platforms, ref shift, gameTime);
            Shoot(oldState, newState, playerBullets, content);
            if (canMoveRight(gameWindow, platforms, shift) && newState.IsKeyDown(Keys.Right))
            {
                position.X += velocity.X;
                changeShift(ref shift, gameWindow);
            }
            if (canMoveLeft(gameWindow, platforms, shift) && newState.IsKeyDown(Keys.Left))
            {
                position.X -= velocity.X;
                changeShift(ref shift, gameWindow);
            }
            oldState = newState;
            EndGame();
        }
Exemplo n.º 5
0
 public int DamageDealt(PlayerBullets bullets, Enemy enemy)
 {
     return(bullets.DamageDealt(enemy));
 }
Exemplo n.º 6
0
        public void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, int shift, Player Player, PlayerBullets bullets, ContentManager content)
        {
            GetHurt(bullets, Player);
            List <Enemy> enemiesToDelete = new List <Enemy>();

            foreach (var item in enemies)
            {
                if (item.isOnScreen(gameWindow, shift))
                {
                    item.Update(gameTime, gameWindow, platforms, ref shift, Player, content);
                }
                if ((!item.isOnScreen(gameWindow, shift) && item.appeared) || !item.IsAlive())
                {
                    enemiesToDelete.Add(item);
                }
            }
            foreach (var item in enemiesToDelete)
            {
                enemies.Remove(item);
            }
        }