Пример #1
0
        /// <summary>
        /// Handles any actions that occurs after the enter key is pressed.
        /// </summary>
        private void EnterKeyPressed()
        {
            // If the player is in the command panel
            if (!_uiStateTracker.IsInActionPanel &&
                !_uiStateTracker.IsInFormationPanel &&
                !_uiStateTracker.IsInCategoryPanel &&
                !_uiStateTracker.IsInCharacterPanel)
            {
                switch ((Commands)_uiStateTracker.CommandFocusNumber)
                {
                case Commands.Attack:
                    _uiStateTracker.IsInActionPanel  = true;
                    _uiStateTracker.IsInCommandPanel = false;
                    UpdateActionListEvent?.Invoke(this, new UpdateActionListEventArgs()
                    {
                        CommandFocus = (Commands)_uiStateTracker.CommandFocusNumber,
                        CategoryName = _uiStateTracker.ActiveCategory
                    });
                    break;

                case Commands.Spells:
                case Commands.Skills:
                case Commands.Items:
                    if (_uiStateTracker.CategoryItemCount > 0)
                    {
                        _uiStateTracker.IsInCategoryPanel = true;
                        _uiStateTracker.IsInCommandPanel  = false;
                    }
                    break;

                case Commands.Status:
                    _uiStateTracker.IsInFormationPanel = true;
                    _uiStateTracker.IsInCommandPanel   = false;
                    _uiStateTracker.IsInStatusCommand  = true;
                    int?position = _uiCharacterManager.GetPositionOfCharacter(_uiStateTracker.ActiveCharacterId);

                    if (position == null)
                    {
                        throw new Exception("Active character was not found in UICharacterManager.");
                    }
                    else
                    {
                        _uiStateTracker.CurrentTargetPosition  = position.GetValueOrDefault();
                        _uiStateTracker.CurrentTargetPositions = new List <int>()
                        {
                            position.GetValueOrDefault()
                        };
                        _uiStateTracker.ActiveAction.CanSwitchTargetPosition = true;
                        _uiStateTracker.ActiveAction.CanTargetThroughUnits   = true;
                        _uiStateTracker.ActiveAction.CenterOfTargets         = 5;
                        _uiStateTracker.ActiveAction.TargetPositions         = new List <int>()
                        {
                            5
                        };
                        _uiStateTracker.IsInStatusCommand = true;
                    }
                    break;

                case Commands.Wait:
                    ActionStartedEvent?.Invoke(this, new ActionStartedEventArgs()
                    {
                        ActionType     = Commands.Wait,
                        CategoryName   = "",
                        ActionIndex    = -1,
                        TargetPosition = 0
                    });
                    break;
                }
            }
            // If the player is in the formation panel, start an action
            else if (_uiStateTracker.IsInFormationPanel && !_uiStateTracker.IsInStatusCommand)
            {
                var target = _uiStateTracker.CurrentTargetPosition;

                ActionStartedEvent?.Invoke(this, new ActionStartedEventArgs()
                {
                    ActionType     = (Commands)_uiStateTracker.CommandFocusNumber,
                    CategoryName   = _uiStateTracker.ActiveCategory,
                    ActionIndex    = _uiStateTracker.ActionFocusNumber - 1,
                    TargetPosition = target
                });
            }
            else if (_uiStateTracker.IsInStatusCommand && !_uiStateTracker.IsInCharacterPanel)
            {
                if (_uiCharacterManager.CharacterInPositionExists(_uiStateTracker.CurrentTargetPosition))
                {
                    _uiStateTracker.IsInCharacterPanel = true;
                    _uiStateTracker.IsInFormationPanel = false;
                }
            }
            // If the player is in the action panel, switch to the formation panel
            else if (_uiStateTracker.IsInActionPanel)
            {
                switch ((Commands)_uiStateTracker.CommandFocusNumber)
                {
                case Commands.Attack:
                case Commands.Spells:
                case Commands.Skills:
                case Commands.Items:
                    _uiStateTracker.IsInFormationPanel = true;
                    _uiStateTracker.IsInActionPanel    = false;
                    ActionSelectedEvent?.Invoke(this, new ActionSelectedEventArgs()
                    {
                        CommandFocus      = (Commands)_uiStateTracker.CommandFocusNumber,
                        CategoryName      = _uiStateTracker.ActiveCategory,
                        ActionFocusNumber = _uiStateTracker.ActionFocusNumber
                    });
                    break;

                default:
                    break;
                }
            }
            else if (_uiStateTracker.IsInCategoryPanel)
            {
                // Get all spells or skills in category
                UpdateActionListEvent?.Invoke(this, new UpdateActionListEventArgs()
                {
                    CommandFocus = (Commands)_uiStateTracker.CommandFocusNumber,
                    CategoryName = _uiStateTracker.ActiveCategory
                });

                _uiStateTracker.IsInActionPanel   = true;
                _uiStateTracker.IsInCategoryPanel = false;
            }
        }
Пример #2
0
 private void InvokeSelectedEvent(string name, int index)
 {
     actionSelectedEvent?.Invoke(typeof(ActionSystem).GetMethod(name), index);
 }