summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/definitions/actor/Player.tres4
-rw-r--r--assets/definitions/actor/Skeleton.tres4
-rw-r--r--assets/sprites/generic_grave.pngbin0 -> 173 bytes
-rw-r--r--assets/sprites/generic_grave.png.import34
-rw-r--r--assets/sprites/generic_grave.pxobin0 -> 820 bytes
-rw-r--r--scenes/Game.tscn2
-rw-r--r--scripts/actors/Actor.cs60
-rw-r--r--scripts/actors/ActorDefinition.cs4
-rw-r--r--scripts/actors/Enemy.cs6
-rw-r--r--scripts/actors/actions/BumpAction.cs2
-rw-r--r--scripts/actors/actions/DirectionalAction.cs14
-rw-r--r--scripts/actors/actions/MeleeAction.cs18
-rw-r--r--scripts/actors/actions/MovementAction.cs6
-rw-r--r--scripts/input/BaseInputHandler.cs.uid1
-rw-r--r--scripts/input/InputHandler.cs (renamed from scripts/InputHandler.cs)16
-rw-r--r--scripts/input/InputHandler.cs.uid (renamed from scripts/InputHandler.cs.uid)0
16 files changed, 141 insertions, 30 deletions
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
--- /dev/null
+++ b/assets/sprites/generic_grave.png
Binary files 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
--- /dev/null
+++ b/assets/sprites/generic_grave.pxo
Binary files 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/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;
/// <summary>
- /// Se o ator bloqueia movimento (não pode oculpar a mesma célula de outro ator.)
- /// </summary>
+ /// Se o ator bloqueia movimento (não pode oculpar a mesma célula de outro ator.)
+ /// </summary>
public bool BlocksMovement {
- get => definition.blocksMovement;
+ get => blocksMovement;
}
+ private string actorName;
/// <summary>
/// Nome do ator.
/// </summary>
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
/// <param name="definition">A definição do ator.</param>
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;
-
/// <summary>
/// Define de forma genérica as características de um ator.
/// </summary>
@@ -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.
/// </summary>
public Vector2I Offset { get; private set; }
+ /// <summary>
+ /// Coordenada do alvo da ação.
+ /// </summary>
+ public Vector2I Destination { get => actor.GridPosition + Offset; }
public DirectionalAction(Actor actor, Vector2I offset) : base(actor)
{
Offset = offset;
}
/// <summary>
- /// É 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.
/// </summary>
- /// <param name="pos">Posição para verificar</param>
- /// <returns>O ator naquela posição, nulo se não houver.</returns>
- protected Actor GetBlockingActorAtPosition(Vector2I pos) {
- return Map_Data.GetBlockingActorAtPosition(pos);
+ /// <returns>O ator alvo da ação, nulo se não houver.</returns>
+ 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
/// </summary>
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/InputHandler.cs b/scripts/input/InputHandler.cs
index 39016ed..838790e 100644
--- a/scripts/InputHandler.cs
+++ b/scripts/input/InputHandler.cs
@@ -19,14 +19,16 @@ public partial class InputHandler : Node {
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 (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);
}
- }
-
- if (Input.IsActionJustPressed("skip-turn")) {
- action = new WaitAction(player);
}
return action;
diff --git a/scripts/InputHandler.cs.uid b/scripts/input/InputHandler.cs.uid
index 302a3b5..302a3b5 100644
--- a/scripts/InputHandler.cs.uid
+++ b/scripts/input/InputHandler.cs.uid