public void GetHurt(PlayerBullets bullets, Player player) { foreach (var item in enemies) { item.HP -= player.DamageDealt(bullets, item); } }
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"); }
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); } } } }
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(); }
public int DamageDealt(PlayerBullets bullets, Enemy enemy) { return(bullets.DamageDealt(enemy)); }
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); } }