예제 #1
0
        /// <summary>
        /// Whenever an action is selected by the player, changes the defaults to the new action to be used in combat.
        /// </summary>
        /// <param name="sender">The object invoking the event.</param>
        /// <param name="args">Event parameters for the ActionSelectedEvent</param>
        private void OnActionSelected(object sender, ActionSelectedEventArgs args)
        {
            var activeAction = _displayManager.GetActionFromCategory(args.CommandFocus,
                                                                     args.CategoryName,
                                                                     args.ActionFocusNumber - 1);

            _defaultsHandler.ActiveAction = new ActionStore()
            {
                TargetPositions         = activeAction.GetActionTargets(),
                CenterOfTargets         = activeAction.GetCenterOfTargetsPosition(),
                CanSwitchTargetPosition = activeAction.CanSwitchTargetPosition,
                CanTargetThroughUnits   = activeAction.CanTargetThroughUnits
            };

            if (_defaultsHandler.CurrentTargetPosition < 1 ||
                _defaultsHandler.CurrentTargetPosition > 18 ||
                !activeAction.CanTargetThroughUnits)
            {
                _defaultsHandler.CurrentTargetPosition = 13;
            }

            _defaultsHandler.CurrentTargetPositions = CombatTargeter.GetTranslatedTargetPositions(_defaultsHandler.ActiveAction.TargetPositions,
                                                                                                  _defaultsHandler.ActiveAction.CenterOfTargets,
                                                                                                  _defaultsHandler.ActiveAction.CanSwitchTargetPosition,
                                                                                                  _defaultsHandler.CurrentTargetPosition);
        }
예제 #2
0
        /// <summary>
        /// Returns a read-only list containing the action details panel injected with data from the a
        /// provided action.
        /// </summary>
        /// <param name="action">The action to display in the panel.</param>
        /// <param name="data">The data of the action to display.</param>
        /// <returns>A read-only list containing the panel.</returns>
        public IReadOnlyList <string> Render()
        {
            if (!_defaultsHandler.IsPlayerTurn)
            {
                return(RenderBlankPanel());
            }

            var action = _displayManager.GetActionFromCategory((Commands)_defaultsHandler.CommandFocusNumber,
                                                               _defaultsHandler.ActiveCategory,
                                                               _defaultsHandler.ActionFocusNumber - 1);

            var data = _viewModelController.GetActionViewData((Commands)_defaultsHandler.CommandFocusNumber,
                                                              _defaultsHandler.ActiveCategory,
                                                              _defaultsHandler.ActionFocusNumber - 1);

            if (action == null)
            {
                return(RenderBlankPanel());
            }

            // If data is the same as previous render, use cached render instead of rerendering
            if (action.GetId() == _cachedActionId && data == _cachedActionData)
            {
                return(_cachedRender);
            }
            else
            {
                _cachedActionId   = action.GetId();
                _cachedActionData = data;
            }

            string navTriangle = "";

            if (data.StatusEffects.Any() && IsActive)
            {
                navTriangle = "Tab ► ";
            }

            var actionPanel = new List <string>();

            actionPanel.Add("╔" + new string('═', MaxWidth - 2) + "╗");
            int spaces = MaxWidth - 2 - action.GetDisplayName().Count() - navTriangle.Length;

            actionPanel.Add("║ " + action.GetDisplayName() + new string(' ', spaces - 1) + navTriangle + "║");
            actionPanel.Add("║" + new string('─', MaxWidth - 2) + "║");
            var actionTargetBoxes = RenderActionTargets(action);
            var actionDescription = RenderActionDescription(action, data);

            for (int i = 0; i < actionTargetBoxes.Count(); i++)
            {
                actionPanel.Add(actionDescription.ElementAt(i) + actionTargetBoxes.ElementAt(i));
            }
            int size = actionPanel.Count();

            for (int i = 0; i < MaxHeight - size - 1; i++)
            {
                actionPanel.Add("║" + new string(' ', MaxWidth - 2) + "║");
            }
            actionPanel.Add("╚" + new string('═', MaxWidth - 2) + "╝");

            _cachedRender = actionPanel;
            return(actionPanel);
        }