public override void Initialize() { _gameState = _game.Services.GetService<GameState>(); _inputDisplay = new InputSequenceDisplay(Game); _inputDisplay.Initialize(); // Game Over _gameOver = new GameOver(Game); _gameOver.Initialize(); // Level finished _levelFinished = new LevelFinished(Game); _levelFinished.Initialize(); _inventoryComponent = new InventoryComponent(Game); _inventoryComponent.Initialize(); _heartbeatComponent = new HeartbeatComponent(Game); _heartbeatComponent.Initialize(); // Player health _playerHealthBar = new ProgressBar(Game, @"Textures\UI\Health", @"Textures\UI\HealthVessel") { DestinationRectangle = new Rectangle(64, 24, 250, 24), Max = _gameState.Player.MaxHealth }; _playerHealthBar.Initialize(); base.Initialize(); }
public void Initialize(Game game, SpriteBatch spriteBatch, ICamera2D camera) { if (IsInitialized) { throw new InvalidOperationException("This level has already been initialized."); } _game = game; _spriteBatch = spriteBatch; InitializeReactions(); LevelFinishedComponent = new LevelFinished(_game); LevelFinishedComponent.Initialize(); // We also initialize all predefined level objects that were specified before Initialize call. // Note that this behavior may change in the future. for (int index = 0; index < CustomLevelObjects.Count; index++) { var levelObject = CustomLevelObjects[index]; levelObject.Initialize(game, spriteBatch, camera); } for (int index = 0; index < Texts.Count; index++) { var text = Texts[index]; text.Initialize(); } IsInitialized = true; }