public void PassInput(PlayerAction action) { if (action == PlayerAction.ESCAPE_SCREEN) { RogueUIPanel.ExitTopLevel(); } }
public void OpenTargetting(Targeting t, BoolDelegate returnCall) { if (targetting.Setup(t, returnCall)) //Different from normal, to encapsulate skipping behaviour that's possible. { targetting.Activate(); } else { RogueUIPanel.ExitAllWindows(); //SWITCH THIS TO UI CONTROLLER WHEN THAT'S IN } }
public void Activate() { gameObject.SetActive(true); panels.Add(this); if (inFocus) { inFocus.Defocus(); } inFocus = this; Focus(); OnActivation(); }
public static void AttemptExitTopLevel() { if (panels.Count == 0) { //Made this not an error, just in case of weird jankiness Debug.Log("Can't deactivate top level UI when there are no panels open."); } else { RogueUIPanel toRemove = panels[panels.Count - 1]; if (toRemove.canBeEscaped) { ExitTopLevel(); } } }
public void HandleInput() { Tuple <PlayerAction, string> pair = InputTracking.PopNextPair(); PlayerAction action = pair.Item1; string inputString = pair.Item2; switch (action) { case PlayerAction.ESCAPE_SCREEN: //Breaks free early, so panels themselves don't have to all try to handle this input. RogueUIPanel.AttemptExitTopLevel(); break; default: RogueUIPanel.inFocus.HandleInput(action, inputString); break; } }
public static void ExitTopLevel() { if (panels.Count == 0) { //Made this not an error, just in case of weird jankiness Debug.Log("Can't deactivate top level UI when there are no panels open."); } else { RogueUIPanel toRemove = panels[panels.Count - 1]; toRemove.Deactivate(); panels.RemoveAt(panels.Count - 1); if (panels.Count != 0) { inFocus = panels[panels.Count - 1]; inFocus.Focus(); } } }
public override IEnumerator DetermineAction() { if (InputTracking.HasNextAction()) { Player.player.view.CollectEntities(Map.current); PlayerAction action = InputTracking.PopNextAction(); switch (action) { //Handle Movement code case PlayerAction.MOVE_UP: nextAction = new MoveAction(monster.location + Vector2Int.up); break; case PlayerAction.MOVE_DOWN: nextAction = new MoveAction(monster.location + Vector2Int.down); break; case PlayerAction.MOVE_LEFT: nextAction = new MoveAction(monster.location + Vector2Int.left); break; case PlayerAction.MOVE_RIGHT: nextAction = new MoveAction(monster.location + Vector2Int.right); break; case PlayerAction.MOVE_UP_LEFT: nextAction = new MoveAction(monster.location + new Vector2Int(-1, 1)); break; case PlayerAction.MOVE_UP_RIGHT: nextAction = new MoveAction(monster.location + new Vector2Int(1, 1)); break; case PlayerAction.MOVE_DOWN_LEFT: nextAction = new MoveAction(monster.location + new Vector2Int(-1, -1)); break; case PlayerAction.MOVE_DOWN_RIGHT: nextAction = new MoveAction(monster.location + new Vector2Int(1, -1)); break; case PlayerAction.WAIT: nextAction = new WaitAction(); break; case PlayerAction.DROP_ITEMS: Debug.Log("Dropping items!"); UIController.singleton.OpenInventoryDrop(); yield return(new WaitUntil(() => !UIController.WindowsOpen)); break; case PlayerAction.PICK_UP_ITEMS: //Intelligently pick up items, opening dialouge box if needed. PickupSmartDetection(); //Check if dialouge box is opened; if so, freeze until transaction is done if (UIController.WindowsOpen) { yield return(new WaitUntil(() => !UIController.WindowsOpen)); } break; case PlayerAction.OPEN_INVENTORY: UIController.singleton.OpenInventoryInspect(); yield return(new WaitUntil(() => !UIController.WindowsOpen)); break; case PlayerAction.EQUIP: UIController.singleton.OpenEquipmentInspect(); yield return(new WaitUntil(() => !UIController.WindowsOpen)); break; case PlayerAction.UNEQUIP: UIController.singleton.OpenEquipmentUnequip(); yield return(new WaitUntil(() => !UIController.WindowsOpen)); break; case PlayerAction.APPLY: UIController.singleton.OpenInventoryApply(); yield return(new WaitUntil(() => !UIController.WindowsOpen)); break; case PlayerAction.CAST_SPELL: UIController.singleton.OpenAbilities(); yield return(new WaitUntil(() => !UIController.WindowsOpen)); break; case PlayerAction.FIRE: nextAction = new RangedAttackAction(); break; case PlayerAction.ASCEND: if (AutoStairs(true)) { nextAction = new ChangeLevelAction(true); } else { //TODO: Highlight path to nearest stair! yield return(new WaitUntil(() => InputTracking.HasNextAction())); PlayerAction newAction = InputTracking.PopNextAction(); if (newAction == PlayerAction.ASCEND) { PathToNearestStair(true); } } break; case PlayerAction.DESCEND: if (AutoStairs(false)) { nextAction = new ChangeLevelAction(false); } else { //TODO: Highlight path to nearest stair! //TODO: This whole waiting and checking thing should be reworked //as a variant of the FindNearest Action yield return(new WaitUntil(() => InputTracking.HasNextAction())); PlayerAction newAction = InputTracking.PopNextAction(); if (newAction == PlayerAction.DESCEND) { PathToNearestStair(false); } } break; case PlayerAction.AUTO_ATTACK: nextAction = new AutoAttackAction(); break; case PlayerAction.AUTO_EXPLORE: nextAction = new AutoExploreAction(); break; //Handle potentially weird cases (Thanks, Nethack design philosophy!) case PlayerAction.ESCAPE_SCREEN: //TODO: Open up the pause menu screen here RogueUIPanel.ExitTopLevel(); //This really, really shouldn't do anything. Let it happen, though! break; case PlayerAction.ACCEPT: case PlayerAction.NONE: Debug.Log("Player read an input set to do nothing", this); break; default: Debug.LogError($"Player read an input that has no switch case: {action}"); break; } } }