From 358943907bc9e37d26618ee03adf1ffd97635335 Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 28 Aug 2025 17:01:53 -0300 Subject: Combate corpo a corpo. --- assets/definitions/actor/Player.tres | 4 +- assets/definitions/actor/Skeleton.tres | 4 +- assets/sprites/generic_grave.png | Bin 0 -> 173 bytes assets/sprites/generic_grave.png.import | 34 ++++++++++++++++ assets/sprites/generic_grave.pxo | Bin 0 -> 820 bytes scenes/Game.tscn | 2 +- scripts/InputHandler.cs | 34 ---------------- scripts/InputHandler.cs.uid | 1 - scripts/actors/Actor.cs | 60 ++++++++++++++++++++++++++-- scripts/actors/ActorDefinition.cs | 4 +- scripts/actors/Enemy.cs | 6 +++ scripts/actors/actions/BumpAction.cs | 2 +- scripts/actors/actions/DirectionalAction.cs | 14 ++++--- scripts/actors/actions/MeleeAction.cs | 18 +++++++-- scripts/actors/actions/MovementAction.cs | 6 +-- scripts/input/BaseInputHandler.cs.uid | 1 + scripts/input/InputHandler.cs | 36 +++++++++++++++++ scripts/input/InputHandler.cs.uid | 1 + 18 files changed, 169 insertions(+), 58 deletions(-) create mode 100644 assets/sprites/generic_grave.png create mode 100644 assets/sprites/generic_grave.png.import create mode 100644 assets/sprites/generic_grave.pxo delete mode 100644 scripts/InputHandler.cs delete mode 100644 scripts/InputHandler.cs.uid create mode 100644 scripts/input/BaseInputHandler.cs.uid create mode 100644 scripts/input/InputHandler.cs create mode 100644 scripts/input/InputHandler.cs.uid diff --git a/assets/definitions/actor/Player.tres b/assets/definitions/actor/Player.tres index e1c0bd6..ceb5df9 100644 --- a/assets/definitions/actor/Player.tres +++ b/assets/definitions/actor/Player.tres @@ -1,12 +1,14 @@ -[gd_resource type="Resource" script_class="ActorDefinition" load_steps=3 format=3 uid="uid://cn6xnpwxjudbp"] +[gd_resource type="Resource" script_class="ActorDefinition" load_steps=4 format=3 uid="uid://cn6xnpwxjudbp"] [ext_resource type="Script" uid="uid://crxw1e37xlrrt" path="res://scripts/actors/ActorDefinition.cs" id="1_2k33r"] +[ext_resource type="Texture2D" uid="uid://w0808ug4al66" path="res://assets/sprites/generic_grave.png" id="1_m72ac"] [ext_resource type="Texture2D" uid="uid://dwky8qc2y602k" path="res://assets/sprites/character.png" id="2_2xyvf"] [resource] script = ExtResource("1_2k33r") name = "Jogador" texture = ExtResource("2_2xyvf") +deathTexture = ExtResource("1_m72ac") blocksMovement = true Hp = 12 Mp = 12 diff --git a/assets/definitions/actor/Skeleton.tres b/assets/definitions/actor/Skeleton.tres index 6bc66f5..6fa9d28 100644 --- a/assets/definitions/actor/Skeleton.tres +++ b/assets/definitions/actor/Skeleton.tres @@ -1,5 +1,6 @@ -[gd_resource type="Resource" script_class="EnemyDefinition" load_steps=3 format=3 uid="uid://gt6xqa737dyt"] +[gd_resource type="Resource" script_class="EnemyDefinition" load_steps=4 format=3 uid="uid://gt6xqa737dyt"] +[ext_resource type="Texture2D" uid="uid://w0808ug4al66" path="res://assets/sprites/generic_grave.png" id="1_7fof3"] [ext_resource type="Script" uid="uid://dkfdm2m2scyks" path="res://scripts/actors/EnemyDefinition.cs" id="1_m5x88"] [ext_resource type="Texture2D" uid="uid://dh5sgjdwkps88" path="res://assets/sprites/skeleton.png" id="2_hhidw"] @@ -8,6 +9,7 @@ script = ExtResource("1_m5x88") AI = 1 name = "Eis que leto" texture = ExtResource("2_hhidw") +deathTexture = ExtResource("1_7fof3") blocksMovement = true Hp = 12 Mp = 2 diff --git a/assets/sprites/generic_grave.png b/assets/sprites/generic_grave.png new file mode 100644 index 0000000..e5e8be4 Binary files /dev/null and b/assets/sprites/generic_grave.png differ diff --git a/assets/sprites/generic_grave.png.import b/assets/sprites/generic_grave.png.import new file mode 100644 index 0000000..b1a3143 --- /dev/null +++ b/assets/sprites/generic_grave.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://w0808ug4al66" +path="res://.godot/imported/generic_grave.png-3f586847994f7a7ab210ee6f773f53ed.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/generic_grave.png" +dest_files=["res://.godot/imported/generic_grave.png-3f586847994f7a7ab210ee6f773f53ed.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/sprites/generic_grave.pxo b/assets/sprites/generic_grave.pxo new file mode 100644 index 0000000..944fad9 Binary files /dev/null and b/assets/sprites/generic_grave.pxo differ diff --git a/scenes/Game.tscn b/scenes/Game.tscn index 983b2a8..2003472 100644 --- a/scenes/Game.tscn +++ b/scenes/Game.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" uid="uid://dwubb28wt4bhe" path="res://scripts/Game.cs" id="1_cpr0p"] [ext_resource type="Script" uid="uid://fe2h4is11tnw" path="res://scripts/map/Map.cs" id="3_cpr0p"] -[ext_resource type="Script" uid="uid://ejqmdbc0524i" path="res://scripts/InputHandler.cs" id="3_s0nni"] +[ext_resource type="Script" uid="uid://ejqmdbc0524i" path="res://scripts/input/InputHandler.cs" id="3_s0nni"] [ext_resource type="Script" uid="uid://dwyr067lwqcsj" path="res://scripts/map/DungeonGenerator.cs" id="4_78awf"] [ext_resource type="Script" uid="uid://bereyrj1s46y5" path="res://scripts/map/FieldOfView.cs" id="5_s0nni"] diff --git a/scripts/InputHandler.cs b/scripts/InputHandler.cs deleted file mode 100644 index 39016ed..0000000 --- a/scripts/InputHandler.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Numerics; -using Godot; - -/// -/// Obtém input do usuário. -/// -public partial class InputHandler : Node { - private readonly Godot.Collections.Dictionary 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 Action GetAction(Player player) { - Action action = null; - - foreach (var direction in directions) { - if (Input.IsActionJustPressed(direction.Key)) { - action = new BumpAction(player, direction.Value); - } - } - - if (Input.IsActionJustPressed("skip-turn")) { - action = new WaitAction(player); - } - - return action; - } -} diff --git a/scripts/InputHandler.cs.uid b/scripts/InputHandler.cs.uid deleted file mode 100644 index 302a3b5..0000000 --- a/scripts/InputHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ejqmdbc0524i diff --git a/scripts/actors/Actor.cs b/scripts/actors/Actor.cs index b0e050f..642e9fd 100644 --- a/scripts/actors/Actor.cs +++ b/scripts/actors/Actor.cs @@ -37,18 +37,20 @@ public abstract partial class Actor : Sprite2D get => gridPosition; } + private bool blocksMovement; /// - /// Se o ator bloqueia movimento (não pode oculpar a mesma célula de outro ator.) - /// + /// Se o ator bloqueia movimento (não pode oculpar a mesma célula de outro ator.) + /// public bool BlocksMovement { - get => definition.blocksMovement; + get => blocksMovement; } + private string actorName; /// /// Nome do ator. /// public string ActorName { - get => definition.name; + get => actorName; } private int hp; @@ -64,6 +66,9 @@ public abstract partial class Actor : Sprite2D set { // Esta propriedade impede que o HP seja maior que o máximo. hp = int.Clamp(value, 0, MaxHp); + if (hp <= 0) { + Die(); + } } } @@ -136,6 +141,9 @@ public abstract partial class Actor : Sprite2D /// A definição do ator. public virtual void SetDefinition(ActorDefinition definition) { this.definition = definition; + blocksMovement = definition.blocksMovement; + actorName = definition.name; + ZIndex = 1; Texture = definition.texture; MaxHp = definition.Hp; @@ -147,4 +155,48 @@ public abstract partial class Actor : Sprite2D Def = definition.Def; Men = definition.Men; } + + public virtual void Die() { + //⠀⠀⠀⠀⢠⣤⣤⣤⢠⣤⣤⣤⣤⣄⢀⣠⣤⣤⣄⠀⠀⠀⢀⣠⣤⣤⣄⠀⣤⣤⠀⠀⣠⣤⣤⣤⣤⣤⡄⢠⣤⣤⣤⣄⠀⠀ + //⠀⠀⠀⠀⠈⢹⣿⠉⠈⠉⣿⣿⠉⠉⢾⣿⣉⣉⠙⠀⠀⢀⣾⡟⠉⠉⣿⣧⢸⣿⡄⢠⣿⠏⣿⣿⣉⣉⡁⢸⣿⡏⢉⣿⡷⠀ + //⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⣿⠀⠀⠈⠿⠿⣿⣿⡀⠀⠸⣿⡇⠀⠀⣾⣿⠀⢿⣿⣸⡿⠀⣿⣿⠿⠿⠇⢸⣿⣿⣿⣿⠀⠀ + //⠀⠀⠀⠀⢠⣼⣿⣤⠀⠀⣿⣿⠀⠀⢷⣦⣤⣼⡿⠁⠀⠀⠹⣿⣤⣴⡿⠋⠀⠘⣿⣿⠃⠀⣿⣿⣤⣤⡄⢸⣿⡇⠙⢿⣦⡀ + //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⠀⠀⢀⣰⣶⣶⣶⣿⣿⣿⣿⣷⣶⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⠿⠛⠛⠻⢿⣿⣿⣿⣿⣿⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⢀⢾⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠈⠉⠉⠉⠻⢿⢿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⢠⠏⢸⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⢻⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⢀⠇⠀⠈⠿⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⢀⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⡸⠀⠀⠀⠀⠀⠀⠀⠀⡼⠛⠳⣄⡀⠀⠐⢿⣦⡀⠀⠀⠀⢠⠃⠀⣸⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⢠⠇⠀⠀⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⠉⣳⠟⠒⠻⣿⣦⡀⠀⡘⠀⢰⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⢀⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠃⢠⣄⡀⠈⠙⢿⡌⠁⠀⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠳⣄⣈⢻⡿⠃⢰⠟⠲⣼⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⡰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⡶⢴⠋⠀⠀⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⡴⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠞⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡴⢟⠒⠀⠀⠀⠀⢰⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠏⠀⠀⠈⠉⣿⠇⠀⢀⡎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠠⣤⣤⣀⢰⠏⠉⠙⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣠⠴⠢⠦⠽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⣿⣿⣿⣷⡄⣀⡀⠈⠉⠋⢹⠋⠁⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠿⠿⠿⠿⠿⠦⠈⠀⠀⠀⠸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + + string deathMessage; + + if (Map_Data.Player == this) { + deathMessage = "Você morreu!"; + } else { + deathMessage = $"{ActorName} morreu!"; + } + + GD.Print(deathMessage); + + Texture = definition.deathTexture; + blocksMovement = false; + ZIndex = 0; + actorName = $"Restos mortais de ${actorName}"; + Map_Data.UnregisterBlockingActor(this); + } } \ No newline at end of file diff --git a/scripts/actors/ActorDefinition.cs b/scripts/actors/ActorDefinition.cs index 72eb745..7f67787 100644 --- a/scripts/actors/ActorDefinition.cs +++ b/scripts/actors/ActorDefinition.cs @@ -1,6 +1,5 @@ using Godot; - /// /// Define de forma genérica as características de um ator. /// @@ -14,6 +13,9 @@ public partial class ActorDefinition : Resource // Seu sprite. [Export] public Texture2D texture; + // Sprite de morto + [Export] + public Texture2D deathTexture; [ExportCategory("Mechanics")] // Se o ator bloqueia movimento. diff --git a/scripts/actors/Enemy.cs b/scripts/actors/Enemy.cs index 8cd3a74..19bcd2c 100644 --- a/scripts/actors/Enemy.cs +++ b/scripts/actors/Enemy.cs @@ -46,4 +46,10 @@ public partial class Enemy : Actor break; } } + + public override void Die() { + Soul.QueueFree(); + Soul = null; + base.Die(); + } } diff --git a/scripts/actors/actions/BumpAction.cs b/scripts/actors/actions/BumpAction.cs index def721b..0ce7fbe 100644 --- a/scripts/actors/actions/BumpAction.cs +++ b/scripts/actors/actions/BumpAction.cs @@ -19,7 +19,7 @@ public partial class BumpAction : DirectionalAction Action action; // Se houver um ator no destino, crie uma ação de ataque. - if (GetBlockingActorAtPosition(destination) != null) { + if (GetTargetActor() != null) { action = new MeleeAction(actor, Offset); } else { // Mas se não houver, crie uma ação de movimento. diff --git a/scripts/actors/actions/DirectionalAction.cs b/scripts/actors/actions/DirectionalAction.cs index 8c3c68f..ca2ca95 100644 --- a/scripts/actors/actions/DirectionalAction.cs +++ b/scripts/actors/actions/DirectionalAction.cs @@ -11,18 +11,20 @@ public abstract partial class DirectionalAction : Action /// Seu significado depende da ação que implementará esta classe. /// public Vector2I Offset { get; private set; } + /// + /// Coordenada do alvo da ação. + /// + public Vector2I Destination { get => actor.GridPosition + Offset; } public DirectionalAction(Actor actor, Vector2I offset) : base(actor) { Offset = offset; } /// - /// É conveniente ter acesso à função para obter atores em uma determinada posição. - /// Este método expõe o método de mesmo nome do mapa. + /// Função que obtém o alvo da ação, se houver. /// - /// Posição para verificar - /// O ator naquela posição, nulo se não houver. - protected Actor GetBlockingActorAtPosition(Vector2I pos) { - return Map_Data.GetBlockingActorAtPosition(pos); + /// O ator alvo da ação, nulo se não houver. + protected Actor GetTargetActor() { + return Map_Data.GetBlockingActorAtPosition(Destination); } } diff --git a/scripts/actors/actions/MeleeAction.cs b/scripts/actors/actions/MeleeAction.cs index cf40f1d..c61a803 100644 --- a/scripts/actors/actions/MeleeAction.cs +++ b/scripts/actors/actions/MeleeAction.cs @@ -14,14 +14,24 @@ public partial class MeleeAction : DirectionalAction /// public override void Perform() { - Vector2I destination = actor.GridPosition + Offset; // Eu te disse que este método seria útil. - Actor target = GetBlockingActorAtPosition(destination); + Actor target = GetTargetActor(); // Se não houver um ator na direção, não podemos continuar. if (target == null) return; - // TODO: Implementar ataque. - GD.Print($"Você tenta socar {target.ActorName}, mas como não sobra nada para o beta, você ainda não tem um método de ataque."); + // não podemos ter dano negativo. + int damage = actor.Atk - target.Def; + + string attackDesc = $"{actor.ActorName} ataca {target.ActorName}"; + + if (damage > 0) { + attackDesc += $" e remove {damage} de HP."; + target.Hp -= damage; + } else { + attackDesc += $" mas {target.ActorName} tem músculos de aço."; + } + + GD.Print(attackDesc); } } diff --git a/scripts/actors/actions/MovementAction.cs b/scripts/actors/actions/MovementAction.cs index f86d542..b37f9ae 100644 --- a/scripts/actors/actions/MovementAction.cs +++ b/scripts/actors/actions/MovementAction.cs @@ -11,14 +11,12 @@ public partial class MovementAction : DirectionalAction public override void Perform() { - Vector2I finalDestination = actor.GridPosition + Offset; - // Não anda se o destino for um tile sólido. - if (!Map_Data.IsTileWalkable(finalDestination)) return; + if (!Map_Data.IsTileWalkable(Destination)) return; // Não anda se o destino for oculpado por um ator. // Na maioria dos casos, essa condição nunca é verdadeira. - if (GetBlockingActorAtPosition(finalDestination) != null) return; + if (GetTargetActor() != null) return; actor.Walk(Offset); } diff --git a/scripts/input/BaseInputHandler.cs.uid b/scripts/input/BaseInputHandler.cs.uid new file mode 100644 index 0000000..deae303 --- /dev/null +++ b/scripts/input/BaseInputHandler.cs.uid @@ -0,0 +1 @@ +uid://cl1of0602byx0 diff --git a/scripts/input/InputHandler.cs b/scripts/input/InputHandler.cs new file mode 100644 index 0000000..838790e --- /dev/null +++ b/scripts/input/InputHandler.cs @@ -0,0 +1,36 @@ +using System.Numerics; +using Godot; + +/// +/// Obtém input do usuário. +/// +public partial class InputHandler : Node { + private readonly Godot.Collections.Dictionary 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 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("skip-turn")) { + action = new WaitAction(player); + } + } + + return action; + } +} diff --git a/scripts/input/InputHandler.cs.uid b/scripts/input/InputHandler.cs.uid new file mode 100644 index 0000000..302a3b5 --- /dev/null +++ b/scripts/input/InputHandler.cs.uid @@ -0,0 +1 @@ +uid://ejqmdbc0524i -- cgit v1.2.3