Exemplo n.º 1
0
        private void Initialize(IList <CombatActButton> buttons)
        {
            var acts        = _combatActModule.GetCurrentCombatActs();
            var actsOrdered = acts.OrderBy(x => x.Constrains is null)
                              .ThenBy(x => x.Stats.Duration)
                              .ThenBy(x => x.Constrains?.EnergyCost)
                              .ThenBy(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);
            }
        }
Exemplo n.º 2
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);
        }