diff options
Diffstat (limited to 'scripts/input')
| -rw-r--r-- | scripts/input/BaseInputHandler.cs | 26 | ||||
| -rw-r--r-- | scripts/input/BaseInputHandler.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/input/GameOverInputHandler.cs | 13 | ||||
| -rw-r--r-- | scripts/input/GameOverInputHandler.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/input/InputHandler.cs | 52 | ||||
| -rw-r--r-- | scripts/input/InputHandler.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/input/InspectInputHandler.cs | 58 | ||||
| -rw-r--r-- | scripts/input/InspectInputHandler.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/input/InventoryInputHandler.cs | 65 | ||||
| -rw-r--r-- | scripts/input/InventoryInputHandler.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/input/MainGameInputHandler.cs | 47 | ||||
| -rw-r--r-- | scripts/input/MainGameInputHandler.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/input/PickupInputHandler.cs | 41 | ||||
| -rw-r--r-- | scripts/input/PickupInputHandler.cs.uid | 1 |
14 files changed, 0 insertions, 309 deletions
diff --git a/scripts/input/BaseInputHandler.cs b/scripts/input/BaseInputHandler.cs deleted file mode 100644 index 4e389ed..0000000 --- a/scripts/input/BaseInputHandler.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Godot; - -/// <summary> -/// Classe base para obter ações do usuário. -/// É interessante ter mais de um objeto para obter ações de -/// usuário porque permite limitar certas ações para -/// certos estados do jogo. Atualmente, o jogo -/// possui somente dois estados: Com jogador vivo e com jogador morto. -/// Mas isto pode aumentar. -/// </summary> -public abstract partial class BaseInputHandler : Node { - /// <summary> - /// Método executado quando o input handler entra em cena; - /// </summary> - public virtual void Enter() { } - /// <summary> - /// Método executado quando o input handler sai de cena; - /// </summary> - public virtual void Exit() { } - /// <summary> - /// Obtém uma ação do usuári conforme input. - /// </summary> - /// <param name="player">Jogador</param> - /// <returns>Ação que o jogador escolheu, nulo se nenhuma.</returns> - public abstract Action GetAction(Player player); -} diff --git a/scripts/input/BaseInputHandler.cs.uid b/scripts/input/BaseInputHandler.cs.uid deleted file mode 100644 index deae303..0000000 --- a/scripts/input/BaseInputHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cl1of0602byx0 diff --git a/scripts/input/GameOverInputHandler.cs b/scripts/input/GameOverInputHandler.cs deleted file mode 100644 index 5e41daf..0000000 --- a/scripts/input/GameOverInputHandler.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Godot; - -/// <summary> -/// Esquema de controles para quando o jogador está morto. -/// </summary> -public partial class GameOverInputHandler : BaseInputHandler { - - // Por enquanto não tem nada. - public override Action GetAction(Player player) - { - return null; - } -}
\ No newline at end of file diff --git a/scripts/input/GameOverInputHandler.cs.uid b/scripts/input/GameOverInputHandler.cs.uid deleted file mode 100644 index 14ddfd8..0000000 --- a/scripts/input/GameOverInputHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ogqlb3purl6n diff --git a/scripts/input/InputHandler.cs b/scripts/input/InputHandler.cs deleted file mode 100644 index 67f4abf..0000000 --- a/scripts/input/InputHandler.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Godot; - -public enum InputHandlers -{ - MainGame, - GameOver, - Inspect, - Pickup, - Inventory -} - -/// <summary> -/// Máquina de estado que obtém ações do usuário conforme o estado atual do jogo. -/// </summary> -public partial class InputHandler : Node -{ - private Godot.Collections.Dictionary<InputHandlers, BaseInputHandler> inputHandlers = []; - - [Export] - private InputHandlers startingInputHandler; - - private BaseInputHandler selectedInputHandler; - - public override void _Ready() - { - base._Ready(); - // Controles para quando o jogador está vivo e jogando normalmente. - inputHandlers.Add(InputHandlers.MainGame, GetNode<MainGameInputHandler>("MainGameInputHandler")); - // Controles para quando o jogador está morto. - inputHandlers.Add(InputHandlers.GameOver, GetNode<GameOverInputHandler>("GameOverInputHandler")); - inputHandlers.Add(InputHandlers.Inspect, GetNode<InspectInputHandler>("InspectInputHandler")); - inputHandlers.Add(InputHandlers.Pickup, GetNode<PickupInputHandler>("PickupInputHandler")); - inputHandlers.Add(InputHandlers.Inventory, GetNode<InventoryInputHandler>("InventoryInputHandler")); - - SetInputHandler(startingInputHandler); - } - - public Action GetAction(Player player) { - return selectedInputHandler.GetAction(player); - } - - /// <summary> - /// Define o esquema de controle atual do jogo - /// para o estado informado. - /// </summary> - /// <param name="inputhandler">Estado do jogo.</param> - public void SetInputHandler(InputHandlers inputhandler) { - selectedInputHandler?.Exit(); - selectedInputHandler = inputHandlers[inputhandler]; - selectedInputHandler.Enter(); - } -} diff --git a/scripts/input/InputHandler.cs.uid b/scripts/input/InputHandler.cs.uid deleted file mode 100644 index f61cdba..0000000 --- a/scripts/input/InputHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bxt6g7t1uvvia diff --git a/scripts/input/InspectInputHandler.cs b/scripts/input/InspectInputHandler.cs deleted file mode 100644 index ad76c62..0000000 --- a/scripts/input/InspectInputHandler.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Godot; - -/// <summary> -/// TODO: Esta solução é nojenta e precisa ser retrabalhada. -/// </summary> -public partial class InspectInputHandler : BaseInputHandler -{ - private static readonly PackedScene InspectorScene = GD.Load<PackedScene>("res://scenes/Inspector.tscn"); - - private readonly Godot.Collections.Dictionary<string, Vector2I> directions = new() - { - {"walk-up", Vector2I.Up}, - {"walk-down", Vector2I.Down}, - {"walk-left", Vector2I.Left}, - {"walk-right", Vector2I.Right}, - {"walk-up-right", Vector2I.Up + Vector2I.Right}, - {"walk-up-left", Vector2I.Up + Vector2I.Left}, - {"walk-down-right", Vector2I.Down + Vector2I.Right}, - {"walk-down-left", Vector2I.Down + Vector2I.Left}, - }; - /// <summary> - /// Preciso disso - /// </summary> - [Export] - private Map map; - - private Inspector inspector; - - public override void Enter() { - SignalBus.Instance.EmitSignal(SignalBus.SignalName.EnterInspectionMode); - inspector = InspectorScene.Instantiate<Inspector>(); - - inspector.GridPosition = map.Map_Data.Player.GridPosition; - - map.AddChild(inspector); - } - - public override void Exit() { - inspector.QueueFree(); - - SignalBus.Instance.EmitSignal(SignalBus.SignalName.ExitInspectionMode); - } - public override Action GetAction(Player player) - { - Action action = null; - foreach (var direction in directions) { - if (Input.IsActionJustPressed(direction.Key)) { - inspector.Walk(direction.Value); - } - } - - if (Input.IsActionJustPressed("quit")) { - GetParent<InputHandler>().SetInputHandler(InputHandlers.MainGame); - } - - return action; - } -}
\ No newline at end of file diff --git a/scripts/input/InspectInputHandler.cs.uid b/scripts/input/InspectInputHandler.cs.uid deleted file mode 100644 index 20141fa..0000000 --- a/scripts/input/InspectInputHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bamlnrj5bm1rd diff --git a/scripts/input/InventoryInputHandler.cs b/scripts/input/InventoryInputHandler.cs deleted file mode 100644 index 98f8576..0000000 --- a/scripts/input/InventoryInputHandler.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Godot; - -public partial class InventoryInputHandler : BaseInputHandler -{ - private static readonly PackedScene inventoryScene = GD.Load<PackedScene>("res://scenes/GUI/invetory_menu.tscn"); - - private InventoryMenu inventoryMenu; - - ConsumableItem activationItem = null; - ConsumableItem dropItem = null; - - [Export] - private Map map; - - public override void Enter() { - inventoryMenu = inventoryScene.Instantiate<InventoryMenu>(); - map.Map_Data.Player.AddChild(inventoryMenu); - inventoryMenu.Initialize(map.Map_Data.Player.inventory); - inventoryMenu.ItemSelected += OnItemActivate; - inventoryMenu.ItemDrop += OnItemDrop; - } - - public override void Exit() { - activationItem = null; - dropItem = null; - inventoryMenu.QueueFree(); - } - - public override Action GetAction(Player player) - { - Action action = null; - - if (activationItem != null) { - action = new ItemAction(player, activationItem); - Close(); - } - - if (dropItem != null) { - action = new DropAction(player, dropItem); - Close(); - } - - if (Input.IsActionJustPressed("quit")) { - Close(); - } - - return action; - } - - private void Close() { - GetParent<InputHandler>().SetInputHandler(InputHandlers.MainGame); - } - - private void ActivateItem() { - - } - - private void OnItemActivate(ConsumableItem item) { - activationItem = item; - } - - private void OnItemDrop(ConsumableItem item) { - dropItem = item; - } -}
\ No newline at end of file diff --git a/scripts/input/InventoryInputHandler.cs.uid b/scripts/input/InventoryInputHandler.cs.uid deleted file mode 100644 index b5d0ed9..0000000 --- a/scripts/input/InventoryInputHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bjcjktvyrdh10 diff --git a/scripts/input/MainGameInputHandler.cs b/scripts/input/MainGameInputHandler.cs deleted file mode 100644 index 6bda004..0000000 --- a/scripts/input/MainGameInputHandler.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Godot; - -/// <summary> -/// Esquema de controles principal do jogo. -/// </summary> -public partial class MainGameInputHandler : BaseInputHandler { - private static readonly Godot.Collections.Dictionary<string, Vector2I> directions = new() - { - {"walk-up", Vector2I.Up}, - {"walk-down", Vector2I.Down}, - {"walk-left", Vector2I.Left}, - {"walk-right", Vector2I.Right}, - {"walk-up-right", Vector2I.Up + Vector2I.Right}, - {"walk-up-left", Vector2I.Up + Vector2I.Left}, - {"walk-down-right", Vector2I.Down + Vector2I.Right}, - {"walk-down-left", Vector2I.Down + Vector2I.Left}, - }; - public override Action GetAction(Player player) { - Action action = null; - - if (player.IsAlive) { - foreach (var direction in directions) { - if (Input.IsActionJustPressed(direction.Key)) { - action = new BumpAction(player, direction.Value); - } - } - - if (Input.IsActionJustPressed("open-inventory")) { - GetParent<InputHandler>().SetInputHandler(InputHandlers.Inventory); - } - - if (Input.IsActionJustPressed("pick-item")) { - GetParent<InputHandler>().SetInputHandler(InputHandlers.Pickup); - } - - if (Input.IsActionJustPressed("inspect")) { - GetParent<InputHandler>().SetInputHandler(InputHandlers.Inspect); - } - - if (Input.IsActionJustPressed("skip-turn")) { - action = new WaitAction(player); - } - } - - return action; - } -} diff --git a/scripts/input/MainGameInputHandler.cs.uid b/scripts/input/MainGameInputHandler.cs.uid deleted file mode 100644 index 302a3b5..0000000 --- a/scripts/input/MainGameInputHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ejqmdbc0524i diff --git a/scripts/input/PickupInputHandler.cs b/scripts/input/PickupInputHandler.cs deleted file mode 100644 index 8f4f9b2..0000000 --- a/scripts/input/PickupInputHandler.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Godot; - -/// <summary> -/// Esquema de controles para pegar um item. -/// </summary> -public partial class PickupInputHandler : BaseInputHandler { - private readonly Godot.Collections.Dictionary<string, Vector2I> directions = new() - { - {"walk-up", Vector2I.Up}, - {"walk-down", Vector2I.Down}, - {"walk-left", Vector2I.Left}, - {"walk-right", Vector2I.Right}, - {"walk-up-right", Vector2I.Up + Vector2I.Right}, - {"walk-up-left", Vector2I.Up + Vector2I.Left}, - {"walk-down-right", Vector2I.Down + Vector2I.Right}, - {"walk-down-left", Vector2I.Down + Vector2I.Left}, - {"skip-turn", Vector2I.Zero} - }; - public override Action GetAction(Player player) { - Action action = null; - - if (player.IsAlive) { - foreach (var direction in directions) { - if (Input.IsActionJustPressed(direction.Key)) { - action = new PickupAction(player, direction.Value); - Quit(); - } - } - - if (Input.IsActionJustPressed("quit")) { - Quit(); - } - } - - return action; - } - - private void Quit() { - GetParent<InputHandler>().SetInputHandler(InputHandlers.MainGame); - } -} diff --git a/scripts/input/PickupInputHandler.cs.uid b/scripts/input/PickupInputHandler.cs.uid deleted file mode 100644 index 139dd25..0000000 --- a/scripts/input/PickupInputHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dspqgdxg5jji0 |
