Example #1
0
 private void BackCommand()
 {
     if (_activePanelView.ParentPanel == null)
     {
         return;                                       //Already at root;
     }
     _activePanelView.ClearSelection();
     _activePanelView.SetPanelVisibility(false);
     _activePanelView = _activePanelView.ParentPanel;
     _activePanelView.SelectNext();
 }
Example #2
0
        private CommandPanelView CreatePanel(CommandPanelView parentPanel = null)
        {
            CommandPanelView panelView = _commandPanelFactory.Create();

            panelView.transform.SetParent(_view.CommandPlatesTransform, false);
            panelView.SetPanelVisibility(false);

            if (parentPanel != null)
            {
                panelView.ParentPanel = parentPanel;
            }

            return(panelView);
        }
Example #3
0
        public void Activate()
        {
            if (_activePanelView != null)
            {
                _activePanelView.SetPanelVisibility(false);
            }
            _activePanelView = _characterManager.ActiveCharacter.CommandPanelView;
            _activePanelView.SetPanelVisibility(true);

            _inputManager.OnRight += SelectCommand;
            _inputManager.OnEnter += SelectCommand;
            _inputManager.OnLeft  += BackCommand;
            _inputManager.OnBack  += BackCommand;
            _inputManager.OnDown  += NextCommand;
            _inputManager.OnUp    += PreviousCommand;
        }
Example #4
0
 private void SelectCommand()
 {
     if (_activePanelView.GetActiveAction() == null)
     {
         throw new WarningException("Select command was hit before an item has been selected.");
     }
     if (_activePanelView.GetActiveAction().ChildPanel == null)
     {
         Deactivate();
         _statusesViewController.Activate(_activePanelView.GetActiveAction().Action);
         return;
     }
     _activePanelView = _activePanelView.GetActiveAction().ChildPanel;
     _activePanelView.SetPanelVisibility(true);
     _activePanelView.ParentPanel.ClearSelection();
     if (_activePanelView.GetActiveAction() == null)
     {
         _activePanelView.SelectNext();                                             //Make sure we select the first item if nothing has been selected yet.
     }
 }
Example #5
0
        public void Initialize()
        {
            //if (_characterManager.ActiveCharacter == null) return;

            foreach (ICharacter character in _characterManager.SelectableCharacters)
            {
                CommandPanelView commandPanelView = CreatePanel();
                character.CommandPanelView = commandPanelView;

                //Register root actions
                foreach (IAction action in character.Actions)
                {
                    CommandView commandView = _commandFactory.Create();
                    commandView.Name.text      = action.Name;
                    commandView.Cursor.enabled = false;
                    commandView.Action         = action;
                    commandPanelView.SetChildCommand(commandView);

                    //Register sub actions (eg magic, items, etc)
                    if (action.SubActions == null || action.SubActions.Count == 0)
                    {
                        continue;
                    }

                    CommandPanelView subCommandPanel = CreatePanel(commandPanelView);
                    commandView.ChildPanel = subCommandPanel;

                    foreach (IAction subAction in action.SubActions)
                    {
                        CommandView subCommandView = _commandFactory.Create();
                        subCommandView.Name.text      = subAction.Name;
                        subCommandView.Cursor.enabled = false;
                        subCommandView.Action         = subAction;
                        subCommandPanel.SetChildCommand(subCommandView);
                    }
                }
            }

            Activate();
        }