public override void Draw(GameTime gameTime) { base.Draw(gameTime); if (_sectorViewModel != null) { _sectorViewModel.Draw(gameTime); } DrawHud(); DrawModals(); if (_isBeginTransition) { _loadingAnimCounter += gameTime.ElapsedGameTime.TotalSeconds; _spriteBatch.Begin(); _spriteBatch.Draw(_uiContentStorage.GetHintBackgroundTexture(), Game.GraphicsDevice.Viewport.Bounds, Color.Black); var pointCount = ((int)_loadingAnimCounter) % 4; _spriteBatch.DrawString(_uiContentStorage.GetButtonFont(), "Loading" + new string('.', pointCount), Game.GraphicsDevice.Viewport.Bounds.Center.ToVector2(), Color.White); _spriteBatch.End(); } }
/// <inheritdoc /> public LeaderBoardScreen(Game game, SpriteBatch spriteBatch) : base(game) { _spriteBatch = spriteBatch; var serviceScope = ((LivGame)Game).ServiceProvider; _uiContentStorage = serviceScope.GetRequiredService <IUiContentStorage>(); _dbContext = serviceScope.GetRequiredService <DbContext>(); _goToMainMenuButton = new TextButton( UiResources.MainMenuButtonTitle, _uiContentStorage.GetButtonTexture(), _uiContentStorage.GetButtonFont(), new Rectangle( 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT)); _goToMainMenuButton.OnClick += GoToMainMenuButtonClickHandler; _leaderBoardRecords = _dbContext.GetLeaderBoard(new LeaderboardLimit(limit: 10)); _font = _uiContentStorage.GetButtonFont(); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { base.Draw(gameTime); _spriteBatch.Begin(); _restartButton.Draw(_spriteBatch); _goToMainMenu.Draw(_spriteBatch); _goToNextScreen.Draw(_spriteBatch); var font = _uiContentStorage.GetButtonFont(); _spriteBatch.DrawString( spriteFont: font, text: UiResources.ScoreMenuTitle, position: new Vector2(x: SCORE_MENU_TITLE_POSITION_X, y: SCORE_MENU_TITLE_POSITION_Y), color: Color.White); _spriteBatch.DrawString( spriteFont: font, text: _scoreSummary, position: new Vector2(x: SCORE_MENU_TITLE_POSITION_X * 3, y: SCORE_MENU_TITLE_POSITION_Y * 2), color: Color.White); _spriteBatch.End(); }
public override void Draw(GameTime gameTime) { base.Draw(gameTime); _spriteBatch.Begin(); var font = _uiContentStorage.GetButtonFont(); _spriteBatch.DrawString(font, "Генерация мира", new Vector2(100, 100), Color.White); _generateButton.Draw(_spriteBatch); _spriteBatch.End(); }
/// <inheritdoc /> public ScoresScreen(Game game, SpriteBatch spriteBatch) : base(game) { _spriteBatch = spriteBatch; var serviceScope = ((LivGame)Game).ServiceProvider; var scoreManager = serviceScope.GetRequiredService <IScoreManager>(); _scoreSummary = TextSummaryHelper.CreateTextSummary(scoreManager.Scores); _uiContentStorage = serviceScope.GetRequiredService <IUiContentStorage>(); _globeGenerationScene = new GlobeSelectionScreen(game: game, spriteBatch: spriteBatch); var buttonTexture = _uiContentStorage.GetButtonTexture(); var font = _uiContentStorage.GetButtonFont(); _restartButton = new TextButton( title: UiResources.StartGameButtonTitle, texture: buttonTexture, font: font, rect: new Rectangle( x: RESTART_BUTTON_POSITION_X, y: BUTTON_POSITION_Y, width: BUTTON_WIDTH, height: BUTTON_HEIGHT)); _restartButton.OnClick += RestartButtonClickHandler; _goToMainMenu = new TextButton( title: UiResources.MainMenuButtonTitle, texture: buttonTexture, font: font, rect: new Rectangle( x: RESTART_BUTTON_POSITION_X + (BUTTON_WIDTH_OFFSET * 2), y: BUTTON_POSITION_Y, width: BUTTON_WIDTH, height: BUTTON_HEIGHT)); _goToMainMenu.OnClick += GoToMainMenuButtonClickHandler; _goToNextScreen = new TextButton( title: UiResources.NextScreenButtonTitle, texture: buttonTexture, font: font, rect: new Rectangle( x: RESTART_BUTTON_POSITION_X + (BUTTON_WIDTH_OFFSET * 4), y: BUTTON_POSITION_Y, width: BUTTON_WIDTH, height: BUTTON_HEIGHT)); _goToNextScreen.OnClick += GoToNextScreenButtonClickHandler; }
private void DrawEquipments(SpriteBatch spriteBatch) { if (_currentEquipmentItems is null) { return; } foreach (var item in _currentEquipmentItems) { item.Control.Draw(spriteBatch); if (item.Equipment is not null) { var propTitle = PropHelper.GetPropTitle(item.Equipment); spriteBatch.DrawString(_uiContentStorage.GetButtonFont(), propTitle, new Vector2(item.Control.Rect.Right + 2, item.Control.Rect.Top), Color.Wheat); } else { spriteBatch.DrawString(_uiContentStorage.GetButtonFont(), UiResources.NoneEquipmentTitle, new Vector2(item.Control.Rect.Right + 2, item.Control.Rect.Top), Color.Gray); } } }
private void DrawPerk(PersonPerkUiItem item, SpriteBatch spriteBatch) { var sourceRect = GetPerkIcon(item.Perk); spriteBatch.Draw(_uiContentStorage.GetAttributeBackgroundTexture(), new Vector2(item.UiRect.Left, item.UiRect.Top), Color.White); spriteBatch.Draw(_uiContentStorage.GetAttributeIconsTexture(), new Vector2(item.UiRect.Left, item.UiRect.Top), sourceRect, Color.White); var attributeTitle = GetPerkTitle(item.Perk); spriteBatch.DrawString( _uiContentStorage.GetButtonFont(), attributeTitle, new Vector2(item.UiRect.Right + ATTRIBUTE_ITEM_SPACING, item.UiRect.Top), new Color(195, 180, 155)); }
private void DrawAttribute(PersonStatUiItem item, SpriteBatch spriteBatch) { var sourceRect = GetAttributeIcon(item.Attribute.Type); spriteBatch.Draw(_uiContentStorage.GetAttributeBackgroundTexture(), new Vector2(item.UiRect.Left, item.UiRect.Top), Color.White); spriteBatch.Draw(_uiContentStorage.GetAttributeIconsTexture(), new Vector2(item.UiRect.Left, item.UiRect.Top), sourceRect, Color.White); var attributeTitle = GetAttributeTitle(item.Attribute); var attributeValue = GetAttributeTextValue(item.Attribute); spriteBatch.DrawString( _uiContentStorage.GetButtonFont(), $"{attributeTitle}: {attributeValue}", new Vector2(item.UiRect.Right + ATTRIBUTE_ITEM_SPACING, item.UiRect.Top), new Color(195, 180, 155)); }
public override void Draw(GameTime gameTime) { base.Draw(gameTime); _spriteBatch.Begin(); var font = _uiContentStorage.GetButtonFont(); const string TITLE_TEXT = "Генерация мира"; var titleTextSize = font.MeasureString(TITLE_TEXT); _spriteBatch.DrawString(font, TITLE_TEXT, new Vector2(Game.GraphicsDevice.Viewport.Bounds.Center.X - titleTextSize.X / 2, 100), Color.White); _generateButton.Rect = new Rectangle(Game.GraphicsDevice.Viewport.Bounds.Center.X - BUTTON_WIDTH / 2, 150, BUTTON_WIDTH, BUTTON_HEIGHT); _generateButton.Draw(_spriteBatch); _spriteBatch.End(); }
private void DrawContainer(SpriteBatch spriteBatch) { if (_currentContainerItems is null) { return; } foreach (var item in _currentContainerItems) { item.Control.Draw(spriteBatch); var propTitle = PropHelper.GetPropTitle(item.Prop); if (item.Prop is Resource resource) { propTitle += $" x{resource.Count}"; } spriteBatch.DrawString(_uiContentStorage.GetButtonFont(), propTitle, new Vector2(item.Control.Rect.Right + 2, item.Control.Rect.Top), Color.Wheat); } }
/// <inheritdoc /> public LeaderBoardScreen(Game game, SpriteBatch spriteBatch) : base(game) { _spriteBatch = spriteBatch; var serviceScope = ((LivGame)Game).ServiceProvider; _uiContentStorage = serviceScope.GetRequiredService <IUiContentStorage>(); _goToMainMenu = new TextButton( title: UiResources.MainMenuButtonTitle, texture: _uiContentStorage.GetButtonTexture(), font: _uiContentStorage.GetButtonFont(), rect: new Rectangle( x: GO_TO_MAIN_MENU_BUTTON_POSITION_X, y: GO_TO_MAIN_MENU_BUTTON_POSITION_Y, width: BUTTON_WIDTH, height: BUTTON_HEIGHT)); _goToMainMenu.OnClick += GoToMainMenuButtonClickHandler; //TODO: prepare leader's board table }
public GlobeSelectionScreen(Game game, SpriteBatch spriteBatch) : base(game) { _spriteBatch = spriteBatch; var serviceProvider = ((LivGame)game).ServiceProvider; _uiContentStorage = serviceProvider.GetRequiredService <IUiContentStorage>(); _globeInitializer = serviceProvider.GetRequiredService <IGlobeInitializer>(); _globeLoop = serviceProvider.GetRequiredService <IGlobeLoopUpdater>(); _commandLoop = serviceProvider.GetRequiredService <ICommandLoopUpdater>(); _playerState = serviceProvider.GetRequiredService <ISectorUiState>(); _inventoryState = serviceProvider.GetRequiredService <IInventoryState>(); var buttonTexture = _uiContentStorage.GetButtonTexture(); var font = _uiContentStorage.GetButtonFont(); _generateButton = new TextButton(UiResources.GenerateGlobeButtonTitle, buttonTexture, font, new Rectangle(150, 150, BUTTON_WIDTH, BUTTON_HEIGHT)); _generateButton.OnClick += GenerateButtonClickHandlerAsync; }
protected ModalDialogBase(IUiContentStorage uiContentStorage, GraphicsDevice graphicsDevice) { _shadowTexture = uiContentStorage.GetModalShadowTexture(); _graphicsDevice = graphicsDevice; _backgroundTopTexture = uiContentStorage.GetModalTopTextures()[0]; _backgroundBottomTexture = uiContentStorage.GetModalBottomTextures()[0]; _dialogRect = new Rectangle( (graphicsDevice.Viewport.Width / 2) - (MODAL_WIDTH / 2), (graphicsDevice.Viewport.Height / 2) - (MODAL_HEIGHT / 2), MODAL_WIDTH, MODAL_HEIGHT); _closeButton = new TextButton("X", uiContentStorage.GetButtonTexture(), uiContentStorage.GetButtonFont(), new Rectangle(_dialogRect.Right - CLOSE_BUTTON_SIZE - CLOSE_BUTTON_PADDING, _dialogRect.Top + CLOSE_BUTTON_PADDING, CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE)); _closeButton.OnClick += CloseButton_OnClick; ContentRect = new Rectangle( _dialogRect.Left + MODAL_CONTENT_MARGIN, _dialogRect.Top + MODAL_CONTENT_MARGIN + MODAL_HEADER_HEIGHT, _dialogRect.Right - MODAL_CONTENT_MARGIN, _dialogRect.Bottom - MODAL_CONTENT_MARGIN); }