private void BackCommand() { if (_activePanelView.ParentPanel == null) { return; //Already at root; } _activePanelView.ClearSelection(); _activePanelView.SetPanelVisibility(false); _activePanelView = _activePanelView.ParentPanel; _activePanelView.SelectNext(); }
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); }
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; }
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. } }
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(); }