Пример #1
0
        private void Initialize(IList <CombatActButton> buttons)
        {
            var acts        = _combatActModule.CalcCombatActs();
            var actsOrdered = acts.OrderBy(x => x.Scheme?.Sid).Take(MAX_COMBAT_ACT_COUNT).ToArray();

            foreach (var act in actsOrdered)
            {
                var tags = act.Scheme?.Stats?.Tags?.Where(x => x != null)?.Select(x => x !)?.ToArray() ??
                           Array.Empty <string>();
                var button = new CombatActButton(_uiContentStorage.GetButtonTexture(),
                                                 _uiContentStorage.GetCombatActIconTexture(act.Scheme?.Sid, tags),
                                                 selectedMarkerTexture: _uiContentStorage.GetSelectedButtonMarkerTexture(),
                                                 _buttonGroup,
                                                 act,
                                                 new Rectangle(0, 0, COMBAT_ACT_BUTTON_SIZE, COMBAT_ACT_BUTTON_SIZE));

                button.OnClick += (s, e) =>
                {
                    _sectorUiState.TacticalAct = act;
                    _buttonGroup.Selected      = (CombatActButton?)s;
                };

                if (act == _sectorUiState.TacticalAct)
                {
                    _buttonGroup.Selected = button;
                }

                buttons.Add(button);
            }
        }
Пример #2
0
        /// <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();
        }
Пример #3
0
        public void Draw(SpriteBatch spriteBatch, Rectangle contentRect)
        {
            for (var buttonIndex = 0; buttonIndex < _buttons.Length; buttonIndex++)
            {
                var button        = _buttons[buttonIndex];
                var buttonOffsetX = BUTTON_WIDTH * buttonIndex;
                button.Rect = new Rectangle(
                    contentRect.Left + buttonOffsetX,
                    contentRect.Top,
                    BUTTON_WIDTH,
                    BUTTON_HEIGHT);

                button.Draw(spriteBatch);
            }

            if (_autoplayHintIsShown)
            {
                var titleTextSizeVector = _uiContentStorage.GetHintTitleFont().MeasureString(_autoplayModeButtonTitle);

                var autoplayButtonRect = _autoplayModeButton.Rect;

                var hintRectangle = new Rectangle(
                    autoplayButtonRect.Left,
                    autoplayButtonRect.Top - (int)titleTextSizeVector.Y - (HINT_TEXT_SPACING * 2),
                    (int)titleTextSizeVector.X + (HINT_TEXT_SPACING * 2),
                    (int)titleTextSizeVector.Y + (HINT_TEXT_SPACING * 2));

                spriteBatch.Draw(_uiContentStorage.GetButtonTexture(), hintRectangle, Color.DarkSlateGray);

                spriteBatch.DrawString(_uiContentStorage.GetHintTitleFont(),
                                       _autoplayModeButtonTitle,
                                       new Vector2(hintRectangle.Left + HINT_TEXT_SPACING, hintRectangle.Top + HINT_TEXT_SPACING),
                                       Color.Wheat);
            }
        }
        protected override void DrawContent(SpriteBatch spriteBatch)
        {
            // Separator
            spriteBatch.Draw(_uiContentStorage.GetButtonTexture(),
                             new Rectangle(ContentRect.Center.X, ContentRect.Top, 2, ContentRect.Height), Color.White);

            DrawEquipments(spriteBatch);
            DrawInventory(spriteBatch);

            if (_propContextMenu != null)
            {
                _propContextMenu.Draw(spriteBatch);
            }
            else
            {
                DrawEquipmentHintIfSelected(spriteBatch);
                DrawInventoryHintIfSelected(spriteBatch);
            }
        }
Пример #5
0
        private void DrawCombatActHint(CombatActButton button, SpriteBatch spriteBatch)
        {
            var combatActHintText = CombatActHelper.GetActHintText(button.CombatAct);

            var titleTextSizeVector = _uiContentStorage.GetHintTitleFont().MeasureString(combatActHintText);

            var autoplayButtonRect = button.Rect;

            var hintRectangle = new Rectangle(
                autoplayButtonRect.Left,
                autoplayButtonRect.Top - (int)titleTextSizeVector.Y - (HINT_TEXT_SPACING * 2),
                (int)titleTextSizeVector.X + (HINT_TEXT_SPACING * 2),
                (int)titleTextSizeVector.Y + (HINT_TEXT_SPACING * 2));

            spriteBatch.Draw(_uiContentStorage.GetButtonTexture(), hintRectangle, Color.DarkSlateGray);

            spriteBatch.DrawString(_uiContentStorage.GetHintTitleFont(),
                                   combatActHintText,
                                   new Vector2(hintRectangle.Left + HINT_TEXT_SPACING, hintRectangle.Top + HINT_TEXT_SPACING),
                                   Color.Wheat);
        }
Пример #6
0
        /// <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;
        }
Пример #7
0
        private void DrawContainerHintIfSelected(SpriteBatch spriteBatch)
        {
            if (_hoverContainerItem is null)
            {
                return;
            }

            var inventoryTitle      = PropHelper.GetPropHintText(_hoverContainerItem.Prop);
            var hintTitleFont       = _uiContentStorage.GetHintTitleFont();
            var titleTextSizeVector = hintTitleFont.MeasureString(inventoryTitle);

            const int HINT_TEXT_SPACING = 8;
            var       hintRectangle     = new Rectangle(
                _hoverContainerItem.UiRect.Left,
                _hoverContainerItem.UiRect.Bottom + EQUIPMENT_ITEM_SPACING,
                (int)titleTextSizeVector.X + (HINT_TEXT_SPACING * 2),
                (int)titleTextSizeVector.Y + (HINT_TEXT_SPACING * 2));

            spriteBatch.Draw(_uiContentStorage.GetButtonTexture(), hintRectangle, Color.DarkSlateGray);

            spriteBatch.DrawString(hintTitleFont, inventoryTitle,
                                   new Vector2(hintRectangle.Left + HINT_TEXT_SPACING, hintRectangle.Top + HINT_TEXT_SPACING),
                                   Color.Wheat);
        }
Пример #8
0
        /// <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;
        }
Пример #10
0
        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);
        }
        private void DrawHintIfSelected(SpriteBatch spriteBatch)
        {
            if (_selectedAttributeItem is null)
            {
                return;
            }

            var attributeDescription = GetAttributeDescription(_selectedAttributeItem.Attribute);
            var hintTitleFont        = _uiContentStorage.GetHintTitleFont();
            var titleTextSizeVector  = hintTitleFont.MeasureString(attributeDescription);

            const int HINT_TEXT_SPACING = 8;
            var       hintRectangle     = new Rectangle(
                _selectedAttributeItem.UiRect.Left,
                _selectedAttributeItem.UiRect.Bottom + ATTRIBUTE_ITEM_SPACING,
                (int)titleTextSizeVector.X + (HINT_TEXT_SPACING * 2),
                (int)titleTextSizeVector.Y + (HINT_TEXT_SPACING * 2));

            spriteBatch.Draw(_uiContentStorage.GetButtonTexture(), hintRectangle, Color.DarkSlateGray);

            spriteBatch.DrawString(hintTitleFont, attributeDescription,
                                   new Vector2(hintRectangle.Left + HINT_TEXT_SPACING, hintRectangle.Top + HINT_TEXT_SPACING),
                                   Color.Wheat);
        }