summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/definitions/actor/EntityInspector.tres15
-rw-r--r--assets/sprites/inspector.pngbin0 -> 138 bytes
-rw-r--r--assets/sprites/inspector.png.import34
-rw-r--r--assets/sprites/inspector.pxobin0 -> 806 bytes
-rw-r--r--project.godot10
-rw-r--r--scenes/Game.tscn25
-rw-r--r--scripts/actors/Actor.cs2
-rw-r--r--scripts/actors/Inspector.cs39
-rw-r--r--scripts/actors/Inspector.cs.uid1
-rw-r--r--scripts/input/BaseInputHandler.cs17
-rw-r--r--scripts/input/InputHandler.cs8
-rw-r--r--scripts/input/InspectInputHandler.cs59
-rw-r--r--scripts/input/InspectInputHandler.cs.uid1
-rw-r--r--scripts/input/MainGameInputHandler.cs4
14 files changed, 197 insertions, 18 deletions
diff --git a/assets/definitions/actor/EntityInspector.tres b/assets/definitions/actor/EntityInspector.tres
new file mode 100644
index 0000000..645597b
--- /dev/null
+++ b/assets/definitions/actor/EntityInspector.tres
@@ -0,0 +1,15 @@
+[gd_resource type="Resource" script_class="ActorDefinition" load_steps=2 format=3 uid="uid://bq3mbgtvjgrg3"]
+
+[ext_resource type="Script" uid="uid://crxw1e37xlrrt" path="res://scripts/actors/ActorDefinition.cs" id="1_na4h7"]
+
+[resource]
+script = ExtResource("1_na4h7")
+name = "unnamed"
+blocksMovement = false
+Speed = 0
+Hp = 0
+Mp = 0
+Atk = 0
+Def = 0
+Men = 0
+metadata/_custom_type_script = "uid://crxw1e37xlrrt"
diff --git a/assets/sprites/inspector.png b/assets/sprites/inspector.png
new file mode 100644
index 0000000..431b584
--- /dev/null
+++ b/assets/sprites/inspector.png
Binary files differ
diff --git a/assets/sprites/inspector.png.import b/assets/sprites/inspector.png.import
new file mode 100644
index 0000000..91e5401
--- /dev/null
+++ b/assets/sprites/inspector.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://cjjxf4rbj8gku"
+path="res://.godot/imported/inspector.png-59071a10f60e326dd75b6e0fe8e4d487.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://assets/sprites/inspector.png"
+dest_files=["res://.godot/imported/inspector.png-59071a10f60e326dd75b6e0fe8e4d487.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/inspector.pxo b/assets/sprites/inspector.pxo
new file mode 100644
index 0000000..a5d11e9
--- /dev/null
+++ b/assets/sprites/inspector.pxo
Binary files differ
diff --git a/project.godot b/project.godot
index 6f9a32b..34e4288 100644
--- a/project.godot
+++ b/project.godot
@@ -91,6 +91,16 @@ walk-down-left={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194439,"key_label":0,"unicode":49,"location":0,"echo":false,"script":null)
]
}
+inspect={
+"deadzone": 0.2,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":88,"physical_keycode":0,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null)
+]
+}
+quit={
+"deadzone": 0.2,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
+]
+}
[rendering]
diff --git a/scenes/Game.tscn b/scenes/Game.tscn
index a409a23..7f7eff0 100644
--- a/scenes/Game.tscn
+++ b/scenes/Game.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=9 format=3 uid="uid://u5h6iqyi8wd0"]
+[gd_scene load_steps=10 format=3 uid="uid://u5h6iqyi8wd0"]
[ext_resource type="Script" uid="uid://dwubb28wt4bhe" path="res://scripts/Game.cs" id="1_cpr0p"]
[ext_resource type="Script" uid="uid://ejqmdbc0524i" path="res://scripts/input/MainGameInputHandler.cs" id="3_400sg"]
@@ -6,21 +6,13 @@
[ext_resource type="Script" uid="uid://bxt6g7t1uvvia" 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://ogqlb3purl6n" path="res://scripts/input/GameOverInputHandler.cs" id="4_g4kob"]
+[ext_resource type="Script" uid="uid://bamlnrj5bm1rd" path="res://scripts/input/InspectInputHandler.cs" id="5_g4kob"]
[ext_resource type="Script" uid="uid://bereyrj1s46y5" path="res://scripts/map/FieldOfView.cs" id="5_s0nni"]
[ext_resource type="PackedScene" uid="uid://b4h4xyr1g8o50" path="res://scenes/hud.tscn" id="6_aug50"]
[node name="Game" type="Node"]
script = ExtResource("1_cpr0p")
-[node name="InputHandler" type="Node" parent="."]
-script = ExtResource("3_s0nni")
-
-[node name="MainGameInputHandler" type="Node" parent="InputHandler"]
-script = ExtResource("3_400sg")
-
-[node name="GameOverInputHandler" type="Node" parent="InputHandler"]
-script = ExtResource("4_g4kob")
-
[node name="Map" type="Node2D" parent="."]
script = ExtResource("3_cpr0p")
@@ -37,6 +29,19 @@ script = ExtResource("5_s0nni")
[node name="Actors" type="Node2D" parent="Map"]
+[node name="InputHandler" type="Node" parent="."]
+script = ExtResource("3_s0nni")
+
+[node name="MainGameInputHandler" type="Node" parent="InputHandler"]
+script = ExtResource("3_400sg")
+
+[node name="GameOverInputHandler" type="Node" parent="InputHandler"]
+script = ExtResource("4_g4kob")
+
+[node name="InspectInputHandler" type="Node" parent="InputHandler" node_paths=PackedStringArray("map")]
+script = ExtResource("5_g4kob")
+map = NodePath("../../Map")
+
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2(8, 8)
zoom = Vector2(0.5, 0.5)
diff --git a/scripts/actors/Actor.cs b/scripts/actors/Actor.cs
index 2d22d44..80e8c1d 100644
--- a/scripts/actors/Actor.cs
+++ b/scripts/actors/Actor.cs
@@ -4,7 +4,7 @@ using Godot;
/// A classe de ator define um personagem no jogo.
/// </summary>
[GlobalClass]
-public abstract partial class Actor : Sprite2D
+public partial class Actor : Sprite2D
{
/// <summary>
/// Sinal emitido toda vez que o HP mudar.
diff --git a/scripts/actors/Inspector.cs b/scripts/actors/Inspector.cs
new file mode 100644
index 0000000..0bdab5b
--- /dev/null
+++ b/scripts/actors/Inspector.cs
@@ -0,0 +1,39 @@
+using Godot;
+
+/// <summary>
+/// Isto é uma abominação
+/// </summary>
+public partial class Inspector : Sprite2D
+{
+ private static readonly Texture2D texture = GD.Load<Texture2D>("res://assets/sprites/inspector.png");
+
+ private Vector2I gridPosition = Vector2I.Zero;
+ /// <summary>
+ /// Posição do inspetor no espaço. Diferentemente de Position, GridPosition tem como formato
+ /// os tiles do mapa.
+ /// </summary>
+ public Vector2I GridPosition {
+ set {
+ gridPosition = value;
+ // O sistema de coordenadas do Godot é em pixels, mas faz mais sentido para o jogo utilizar coordenadas em tiles.
+ // Esta propriedade converte um sistema para o outro automaticamente.
+ Position = Grid.GridToWorld(value);
+ }
+ get => gridPosition;
+ }
+
+ public Inspector(Vector2I initialPosition)
+ {
+ GridPosition = initialPosition;
+ Centered = false;
+ Texture = texture;
+ }
+
+ /// <summary>
+ /// O Inspetor não faz parte do mapa.
+ /// </summary>
+ /// <param name="offset"></param>
+ public void Walk(Vector2I offset) {
+ GridPosition += offset;
+ }
+} \ No newline at end of file
diff --git a/scripts/actors/Inspector.cs.uid b/scripts/actors/Inspector.cs.uid
new file mode 100644
index 0000000..ca411e4
--- /dev/null
+++ b/scripts/actors/Inspector.cs.uid
@@ -0,0 +1 @@
+uid://dxsrtu4b3pi08
diff --git a/scripts/input/BaseInputHandler.cs b/scripts/input/BaseInputHandler.cs
index 4ba25d7..4e389ed 100644
--- a/scripts/input/BaseInputHandler.cs
+++ b/scripts/input/BaseInputHandler.cs
@@ -9,11 +9,18 @@ using Godot;
/// Mas isto pode aumentar.
/// </summary>
public abstract partial class BaseInputHandler : Node {
-
- /// <summary>
- /// Obtém uma ação do usuári conforme input.
+ /// <summary>
+ /// Método executado quando o input handler entra em cena;
/// </summary>
- /// <param name="player">Jogador</param>
- /// <returns>Ação que o jogador escolheu, nulo se nenhuma.</returns>
+ 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/InputHandler.cs b/scripts/input/InputHandler.cs
index 873276f..4f5b4e1 100644
--- a/scripts/input/InputHandler.cs
+++ b/scripts/input/InputHandler.cs
@@ -3,7 +3,8 @@ using Godot;
public enum InputHandlers
{
MainGame,
- GameOver
+ GameOver,
+ Inspect
}
/// <summary>
@@ -25,7 +26,8 @@ public partial class InputHandler : Node
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"));
+
SetInputHandler(startingInputHandler);
}
@@ -39,6 +41,8 @@ public partial class InputHandler : Node
/// </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/InspectInputHandler.cs b/scripts/input/InspectInputHandler.cs
new file mode 100644
index 0000000..60c10e4
--- /dev/null
+++ b/scripts/input/InspectInputHandler.cs
@@ -0,0 +1,59 @@
+using Godot;
+
+/// <summary>
+/// TODO: Esta solução é nojenta e precisa ser retrabalhada.
+/// </summary>
+public partial class InspectInputHandler : 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},
+ };
+ /// <summary>
+ /// Preciso disso
+ /// </summary>
+ [Export]
+ private Map map;
+
+ private Inspector inspector;
+
+ public override void Enter() {
+ inspector = new(map.Map_Data.Player.GridPosition)
+ {
+ ZIndex = 4
+ };
+ // Copiamos a câmera do jogador com todas as suas configurações
+ Camera2D camera = (Camera2D) map.Map_Data.Player.GetNode<Camera2D>("Camera2D").Duplicate();
+ inspector.AddChild(camera);
+
+ map.AddChild(inspector);
+ camera.Enabled = true;
+ camera.MakeCurrent();
+ }
+
+ public override void Exit() {
+ inspector.QueueFree();
+ }
+ 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
new file mode 100644
index 0000000..20141fa
--- /dev/null
+++ b/scripts/input/InspectInputHandler.cs.uid
@@ -0,0 +1 @@
+uid://bamlnrj5bm1rd
diff --git a/scripts/input/MainGameInputHandler.cs b/scripts/input/MainGameInputHandler.cs
index 1c5ac6e..c7bf26a 100644
--- a/scripts/input/MainGameInputHandler.cs
+++ b/scripts/input/MainGameInputHandler.cs
@@ -24,6 +24,10 @@ public partial class MainGameInputHandler : BaseInputHandler {
action = new BumpAction(player, direction.Value);
}
}
+
+ if (Input.IsActionJustPressed("inspect")) {
+ GetParent<InputHandler>().SetInputHandler(InputHandlers.Inspect);
+ }
if (Input.IsActionJustPressed("skip-turn")) {
action = new WaitAction(player);