/// <summary> /// Met a jour le jeu avant de lancer un nouveau niveau /// </summary> /// <param name="deltaT">Temps passé depuis le dernier appel a update</param> private void handleInterLevel(double deltaT) { if (keyPressed.Contains(Keys.Space)) { this.state = GameState.RUNNING; this.gameObjects.RemoveWhere(g => g is EnemyGroup || g is Bonus); // On remove l'enemyGroup actuel et les bonus qui droppait player.addBonus(BonusType.INVINCIBILITY, 0); //On clear le bonus actuel this.enemyGroup = new EnemyGroup(); AddNewGameObject(this.enemyGroup); } }
/// <summary> /// Update the gameplay logic. /// </summary> /// <param name="deltaTime"></param> private void UpdateGameplay(float deltaTime) { Player.Update(deltaTime); EnemyGroup.Update(deltaTime); ProjectileController.Update(deltaTime); UfoController.Update(deltaTime); if (EnemyGroup.RemainingEnemyCount > 0) { return; } EnemyGroup.Spawn(); Player.Lives += 1; }
/// <summary> /// Render the gameplay screen. /// </summary> /// <param name="gameTime"></param> public override void Draw(GameTime gameTime) { spriteBatch.DrawLine(HorizontalBoundaryStart, HorizontalBoundaryEnd, ColourHelpers.PureGreen, 2); if (!isGameover) { EnemyGroup.Draw(spriteBatch); UfoController.Draw(spriteBatch); ProjectileController.Draw(spriteBatch); } Player.Draw(spriteBatch); BarrierGroup.Draw(spriteBatch); DrawUI(); DrawGameoverUI(); }
/// <summary> /// Load the content for this gameplay screen. /// </summary> /// <param name="spriteBatch"></param> public override void LoadContent(SpriteBatch spriteBatch) { this.spriteBatch = spriteBatch; // Load fonts hudSpriteFont = MainGame.Context.Content.Load <SpriteFont>("SpaceInvadersFont"); headerSpriteFont = MainGame.Context.Content.Load <SpriteFont>("SpaceInvadersFontHeader"); // Load all the enemy types EnemyType.Load(MainGame.Context.Content); Player = new Player(); BarrierGroup = new BarrierGroup(); Player.InitializeHorizontalPosition(); EnemyGroup = new EnemyGroup(); ProjectileController = new ProjectileController(); UfoController = new UfoController(); }