summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-18 12:06:59 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-18 12:06:59 -0300
commit5146895cf537dd69867da612abed5b4abaf805cd (patch)
tree70212352a07922b58db99ba2564f76ca072af200
parenteacdd15612c70ff86f3446982c46a09272249936 (diff)
ME ELIMINE AAAAAAAAAAAAAAAAAAAAAAAAAAAA
-rw-r--r--project.godot2
-rw-r--r--projeto-fantasia.csproj2
-rw-r--r--projeto-fantasia.csproj.old7
-rw-r--r--scripts/Entities/Actions/Action.cs32
-rw-r--r--scripts/Entities/Actions/DropAction.cs2
-rw-r--r--scripts/Entities/Actions/ItemAction.cs23
-rw-r--r--scripts/Entities/Actions/MeleeAction.cs2
-rw-r--r--scripts/Entities/Actions/MovementAction.cs2
-rw-r--r--scripts/Entities/Actions/PickUpAction.cs15
-rw-r--r--scripts/Entities/Actions/SpellAction.cs4
-rw-r--r--scripts/Entities/Actions/WaitAction.cs2
-rw-r--r--scripts/Entities/Actors/AI/BaseAI.cs8
-rw-r--r--scripts/Entities/Actors/AI/HostileEnemyAI.cs32
-rw-r--r--scripts/Entities/Actors/Actor.cs22
-rw-r--r--scripts/Entities/Actors/ActorDefinition.cs2
-rw-r--r--scripts/Entities/Actors/Enemy.cs8
-rw-r--r--scripts/Entities/Actors/Inventory.cs8
-rw-r--r--scripts/Entities/Actors/Player.cs5
-rw-r--r--scripts/Entities/Entity.cs14
-rw-r--r--scripts/Entities/Items/HealingConsumable.cs2
-rw-r--r--scripts/Entities/Items/ScrollConsumable.cs4
-rw-r--r--scripts/GUI/Details.cs20
-rw-r--r--scripts/GUI/Hud.cs2
-rw-r--r--scripts/GUI/InventoryMenu.cs8
-rw-r--r--scripts/GUI/ItemMenuEntry.cs42
-rw-r--r--scripts/GUI/MainMenu.cs22
-rw-r--r--scripts/GUI/MessageLog.cs6
-rw-r--r--scripts/Game.cs30
-rw-r--r--scripts/InputHandling/InputHandler.cs30
-rw-r--r--scripts/InputHandling/InspectInputHandler.cs16
-rw-r--r--scripts/InputHandling/InventoryInputHandler.cs36
-rw-r--r--scripts/Magic/DamageEffect.cs2
-rw-r--r--scripts/Map/DungeonGenerator.cs57
-rw-r--r--scripts/Map/Map.cs42
-rw-r--r--scripts/Map/MapData.cs4
-rw-r--r--scripts/Map/Tile.cs16
-rw-r--r--scripts/Time/TurnManager.cs30
37 files changed, 263 insertions, 298 deletions
diff --git a/project.godot b/project.godot
index ad54fc4..96c139a 100644
--- a/project.godot
+++ b/project.godot
@@ -13,7 +13,7 @@ config_version=5
config/name="projeto-fantasia"
config/tags=PackedStringArray("based")
run/main_scene="uid://cqrq8cosoge7i"
-config/features=PackedStringArray("4.4", "C#", "Forward Plus")
+config/features=PackedStringArray("4.5", "C#", "Forward Plus")
config/icon="res://icon.svg"
[autoload]
diff --git a/projeto-fantasia.csproj b/projeto-fantasia.csproj
index 800a3c6..2924733 100644
--- a/projeto-fantasia.csproj
+++ b/projeto-fantasia.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Godot.NET.Sdk/4.4.1">
+<Project Sdk="Godot.NET.Sdk/4.5.0">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
diff --git a/projeto-fantasia.csproj.old b/projeto-fantasia.csproj.old
new file mode 100644
index 0000000..800a3c6
--- /dev/null
+++ b/projeto-fantasia.csproj.old
@@ -0,0 +1,7 @@
+<Project Sdk="Godot.NET.Sdk/4.4.1">
+ <PropertyGroup>
+ <TargetFramework>net8.0</TargetFramework>
+ <EnableDynamicLoading>true</EnableDynamicLoading>
+ <RootNamespace>projetofantasia</RootNamespace>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/scripts/Entities/Actions/Action.cs b/scripts/Entities/Actions/Action.cs
index b2d6a4b..0bbcc24 100644
--- a/scripts/Entities/Actions/Action.cs
+++ b/scripts/Entities/Actions/Action.cs
@@ -10,47 +10,29 @@ namespace TheLegendOfGustav.Entities.Actions;
/// </summary>
public abstract partial class Action : RefCounted
{
- private Actor actor;
-
- private int cost;
+ /// <summary>
+ /// O custo da ação.
+ /// </summary>
+ protected int cost;
public Action(Actor actor)
{
Actor = actor;
// Custo base, subclasses podem sobreescrever isto se quiserem.
- Cost = 10;
+ cost = 10;
}
/// <summary>
/// O ator que realiza a ação.
/// </summary>
- public Actor Actor
- {
- get => actor;
- private set
- {
- actor = value;
- }
- }
-
- /// <summary>
- /// O custo da ação.
- /// </summary>
- protected int Cost
- {
- get => cost;
- set
- {
- cost = value;
- }
- }
+ public Actor Actor { get; private set; }
/// <summary>
/// É conveniente ter acesso ao mapa dentro de uma ação.
/// </summary>
protected MapData MapData
{
- get => actor.MapData;
+ get => Actor.MapData;
}
/// <summary>
diff --git a/scripts/Entities/Actions/DropAction.cs b/scripts/Entities/Actions/DropAction.cs
index 00ddd7e..51d4ce6 100644
--- a/scripts/Entities/Actions/DropAction.cs
+++ b/scripts/Entities/Actions/DropAction.cs
@@ -11,7 +11,7 @@ public partial class DropAction : ItemAction
public override bool Perform()
{
- Player.Inventory.Drop(Item);
+ Player.Inventory.Drop(item);
return true;
}
} \ No newline at end of file
diff --git a/scripts/Entities/Actions/ItemAction.cs b/scripts/Entities/Actions/ItemAction.cs
index 14c5d93..a2ca1a2 100644
--- a/scripts/Entities/Actions/ItemAction.cs
+++ b/scripts/Entities/Actions/ItemAction.cs
@@ -5,32 +5,15 @@ namespace TheLegendOfGustav.Entities.Actions;
public partial class ItemAction : Action
{
- private ConsumableItem item;
- private Player player;
+ protected ConsumableItem item;
public ItemAction(Player player, ConsumableItem item) : base(player)
{
- Item = item;
+ this.item = item;
Player = player;
}
- public Player Player
- {
- get => player;
- private set
- {
- player = value;
- }
- }
-
- protected ConsumableItem Item
- {
- get => item;
- set
- {
- item = value;
- }
- }
+ public Player Player { get; private set; }
public override bool Perform()
{
diff --git a/scripts/Entities/Actions/MeleeAction.cs b/scripts/Entities/Actions/MeleeAction.cs
index fcd8368..5e53ec7 100644
--- a/scripts/Entities/Actions/MeleeAction.cs
+++ b/scripts/Entities/Actions/MeleeAction.cs
@@ -49,7 +49,7 @@ public partial class MeleeAction : DirectionalAction
}
MessageLogData.Instance.AddMessage(attackDesc);
- Actor.Energy -= Cost;
+ Actor.Energy -= cost;
return true;
}
}
diff --git a/scripts/Entities/Actions/MovementAction.cs b/scripts/Entities/Actions/MovementAction.cs
index 0ac842c..f78d95d 100644
--- a/scripts/Entities/Actions/MovementAction.cs
+++ b/scripts/Entities/Actions/MovementAction.cs
@@ -23,7 +23,7 @@ public partial class MovementAction : DirectionalAction
if (GetTarget() != null) return true;
Actor.Walk(Offset);
- Actor.Energy -= Cost;
+ Actor.Energy -= cost;
return true;
}
diff --git a/scripts/Entities/Actions/PickUpAction.cs b/scripts/Entities/Actions/PickUpAction.cs
index 0dbd672..eaed01c 100644
--- a/scripts/Entities/Actions/PickUpAction.cs
+++ b/scripts/Entities/Actions/PickUpAction.cs
@@ -12,18 +12,9 @@ public partial class PickupAction : DirectionalAction
public PickupAction(Player player, Vector2I offset) : base(player, offset)
{
- Player = player;
+ this.player = player;
// Pegar itens requer um tempo menor.
- Cost = 2;
- }
-
- protected Player Player
- {
- get => player;
- private set
- {
- player = value;
- }
+ cost = 2;
}
public override bool Perform()
@@ -45,7 +36,7 @@ public partial class PickupAction : DirectionalAction
MapData.RemoveEntity(item);
player.Inventory.Add(item);
- player.Energy -= Cost;
+ player.Energy -= cost;
return true;
}
} \ No newline at end of file
diff --git a/scripts/Entities/Actions/SpellAction.cs b/scripts/Entities/Actions/SpellAction.cs
index d9e9952..28d6caa 100644
--- a/scripts/Entities/Actions/SpellAction.cs
+++ b/scripts/Entities/Actions/SpellAction.cs
@@ -16,7 +16,7 @@ public partial class SpellAction : DirectionalAction
{
this.spell = spell;
- Cost = 5;
+ cost = 5;
}
public override bool Perform()
@@ -53,7 +53,7 @@ public partial class SpellAction : DirectionalAction
effect.Apply(Actor, target);
}
- Actor.Energy -= Cost;
+ Actor.Energy -= cost;
return true;
}
}
diff --git a/scripts/Entities/Actions/WaitAction.cs b/scripts/Entities/Actions/WaitAction.cs
index 011703b..993e4f4 100644
--- a/scripts/Entities/Actions/WaitAction.cs
+++ b/scripts/Entities/Actions/WaitAction.cs
@@ -98,7 +98,7 @@ public partial class WaitAction : Action
//@@@@@@@@@@@@*====+==++=*@. @ @@* .@* @ .*#. @ @* #: -@ @@% @ -+ =*%@@= @@: @ @ +. #+ *@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@======++====+*%@@@@%%%@@@@%*+#@@@@@%#%@@#=+**=. =**+=***==*#*: :%@@@@@@@@@**=+#*==*###*=. -=**+::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@+==+==++=====++=====++=+++++++++===+++++#% +@@@* :#%= =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- Actor.Energy -= Cost;
+ Actor.Energy -= cost;
return true;
}
} \ No newline at end of file
diff --git a/scripts/Entities/Actors/AI/BaseAI.cs b/scripts/Entities/Actors/AI/BaseAI.cs
index bdd1e61..3b9ae3e 100644
--- a/scripts/Entities/Actors/AI/BaseAI.cs
+++ b/scripts/Entities/Actors/AI/BaseAI.cs
@@ -20,13 +20,13 @@ public abstract partial class BaseAI : Node
/// Corpo controlado pela IA.
/// O corpo é a marionete da alma.
/// </summary>
- protected Actor Body { get; set; }
+ protected Actor body;
public override void _Ready()
{
base._Ready();
// Por padrão, a IA é filha do nó de seu corpo.
- Body = GetParent<Actor>();
+ body = GetParent<Actor>();
}
/// <summary>
@@ -42,12 +42,12 @@ public abstract partial class BaseAI : Node
/// </summary>
/// <param name="destination">Destino</param>
/// <returns>Vetor com vetores, passo a passo para chegar no destino.</returns>
- public Godot.Collections.Array<Vector2> GetPathTo(Vector2I destination)
+ protected Godot.Collections.Array<Vector2> GetPathTo(Vector2I destination)
{
// Arrays do Godot são muito mais confortáveis de manipular, então
// eu converto o Array do C# em um array do Godot antes de retornar o caminho.
Godot.Collections.Array<Vector2> list = [];
- Vector2[] path = Body.MapData.Pathfinder.GetPointPath(Body.GridPosition, destination);
+ Vector2[] path = body.MapData.Pathfinder.GetPointPath(body.GridPosition, destination);
list.AddRange(path);
return list;
}
diff --git a/scripts/Entities/Actors/AI/HostileEnemyAI.cs b/scripts/Entities/Actors/AI/HostileEnemyAI.cs
index 2f925c1..62e3d47 100644
--- a/scripts/Entities/Actors/AI/HostileEnemyAI.cs
+++ b/scripts/Entities/Actors/AI/HostileEnemyAI.cs
@@ -12,29 +12,29 @@ public partial class HostileEnemyAI : BaseAI
/// <summary>
/// Caminho até a última posição conhecida do jogador.
/// </summary>
- private Godot.Collections.Array<Vector2> Path { get; set; } = [];
+ private Godot.Collections.Array<Vector2> path = [];
public override void Perform()
{
// O alvo da IA sempre é o jogador.
- Player target = Body.MapData.Player;
+ Player target = body.MapData.Player;
// Vetor que parte do inimigo até o jogador.
- Vector2I offset = target.GridPosition - Body.GridPosition;
+ Vector2I offset = target.GridPosition - body.GridPosition;
// Distância entre o inimigo e o jogador. Leva em consideração somente
// um dos eixos.
- int distance = Grid.Distance(Body.GridPosition, target.GridPosition);
+ int distance = Grid.Distance(body.GridPosition, target.GridPosition);
// A ação executada no turno pode ser de ataque ou de movimento.
Action action;
// Só faz sentido atacar o jogador se o inimigo estiver visível.
- if (Body.MapData.GetTile(Body.GridPosition).IsInView)
+ if (body.MapData.GetTile(body.GridPosition).IsInView)
{
// Se o inimigo consegue ver que o jogador está morto,
// IT'S OVER.
if (!target.IsAlive)
{
- action = new WaitAction(Body);
+ action = new WaitAction(body);
action.Perform();
return;
}
@@ -42,7 +42,7 @@ public partial class HostileEnemyAI : BaseAI
// Se estiver do lado do jogador, ataque.
if (distance <= 1)
{
- action = new MeleeAction(Body, offset);
+ action = new MeleeAction(body, offset);
action.Perform();
// Executada a ação, acabamos nosso turno aqui.
return;
@@ -51,34 +51,34 @@ public partial class HostileEnemyAI : BaseAI
// Se o inimigo estiver visível para o jogador,
// consideramos que ele também consiga ver o jogador.
// Logo, atualizamos o caminho para a posição atual do jogador.
- Path = GetPathTo(target.GridPosition);
+ path = GetPathTo(target.GridPosition);
// O primeiro passo é a posição atual do inimigo, podemos remover.
- Path.RemoveAt(0);
+ path.RemoveAt(0);
}
// Se existir um caminho conhecido para o jogador.
- if (Path.Count > 0)
+ if (path.Count > 0)
{
// Pegamos o próximo passo para o destino.
- Vector2I destination = (Vector2I)Path[0];
+ Vector2I destination = (Vector2I)path[0];
// Se tiver o caminho estiver bloqueado, paramos o nosso turno aqui.
- if (Body.MapData.GetBlockingEntityAtPosition(destination) != null)
+ if (body.MapData.GetBlockingEntityAtPosition(destination) != null)
{
- action = new WaitAction(Body);
+ action = new WaitAction(body);
action.Perform();
return;
}
// Caso o contrário, criamos uma nova ação de movimentação e a executamos.
- action = new MovementAction(Body, destination - Body.GridPosition);
+ action = new MovementAction(body, destination - body.GridPosition);
action.Perform();
// Podemos remover o passo do caminho.
- Path.RemoveAt(0);
+ path.RemoveAt(0);
return;
}
// Senão, espere.
- action = new WaitAction(Body);
+ action = new WaitAction(body);
action.Perform();
return;
}
diff --git a/scripts/Entities/Actors/Actor.cs b/scripts/Entities/Actors/Actor.cs
index 7e228f8..ec00e30 100644
--- a/scripts/Entities/Actors/Actor.cs
+++ b/scripts/Entities/Actors/Actor.cs
@@ -16,6 +16,12 @@ public partial class Actor : Entity
private int hp;
private int energy;
+
+ /// <summary>
+ /// A definição do ator possui caracterísitcas padrões que definem
+ /// o ator em questão.
+ /// </summary>
+ private ActorDefinition definition;
#endregion
#region Constructors
@@ -77,7 +83,7 @@ public partial class Actor : Entity
/// <summary>
/// Taxa de recarga de energia.
/// </summary>
- public int Speed { get => Definition.Speed; }
+ public int Speed { get => definition.Speed; }
/// <summary>
/// HP máximo do ator.
@@ -142,16 +148,6 @@ public partial class Actor : Entity
/// </summary>
public int MpRegenPerTurn { get; private set; } = 5;
- /// <summary>
- /// A definição do ator possui caracterísitcas padrões que definem
- /// o ator em questão.
- /// </summary>
- private ActorDefinition Definition
- {
- get;
- set;
- }
-
public SpellBook SpellBook { get; private set; } = new();
#endregion
@@ -220,7 +216,7 @@ public partial class Actor : Entity
public virtual void SetDefinition(ActorDefinition definition)
{
base.SetDefinition(definition);
- Definition = definition;
+ this.definition = definition;
Type = definition.Type;
@@ -275,7 +271,7 @@ public partial class Actor : Entity
MessageLogData.Instance.AddMessage(deathMessage);
- Texture = Definition.deathTexture;
+ Texture = definition.deathTexture;
BlocksMovement = false;
Type = EntityType.CORPSE;
DisplayName = $"Restos mortais de {DisplayName}";
diff --git a/scripts/Entities/Actors/ActorDefinition.cs b/scripts/Entities/Actors/ActorDefinition.cs
index 5bd8073..bc34cb6 100644
--- a/scripts/Entities/Actors/ActorDefinition.cs
+++ b/scripts/Entities/Actors/ActorDefinition.cs
@@ -15,7 +15,7 @@ public partial class ActorDefinition : EntityDefinition
[ExportCategory("Mechanics")]
[Export]
- public int Speed { get; set; } = 10;
+ public int Speed = 10;
// Estatísticas padrão do ator.
[ExportCategory("Stats")]
diff --git a/scripts/Entities/Actors/Enemy.cs b/scripts/Entities/Actors/Enemy.cs
index c152a0b..d398176 100644
--- a/scripts/Entities/Actors/Enemy.cs
+++ b/scripts/Entities/Actors/Enemy.cs
@@ -10,9 +10,11 @@ namespace TheLegendOfGustav.Entities.Actors;
/// </summary>
public partial class Enemy : Actor
{
+ private EnemyDefinition definition;
+
public Enemy(Vector2I initialPosition, MapData map, EnemyDefinition definition) : base(initialPosition, map, definition)
{
- Definition = definition;
+ this.definition = definition;
SetDefinition(definition);
}
@@ -21,8 +23,6 @@ public partial class Enemy : Actor
/// </summary>
public BaseAI Soul { get; private set; }
- private EnemyDefinition Definition { get; set; }
-
/// <summary>
/// Além de definir as características gerais de um ator,
/// também define qual IA utilizar.
@@ -31,7 +31,7 @@ public partial class Enemy : Actor
public void SetDefinition(EnemyDefinition definition)
{
// Definimos as características do ator.
- base.SetDefinition(Definition);
+ base.SetDefinition(this.definition);
// Definimos qual IA utilizar.
switch (definition.AI)
diff --git a/scripts/Entities/Actors/Inventory.cs b/scripts/Entities/Actors/Inventory.cs
index f65dc59..057316a 100644
--- a/scripts/Entities/Actors/Inventory.cs
+++ b/scripts/Entities/Actors/Inventory.cs
@@ -7,27 +7,27 @@ namespace TheLegendOfGustav.Entities.Actors;
public partial class Inventory(int capacity) : Node
{
- private Player Player { get; set; }
+ private Player player;
public int Capacity { get; private set; } = capacity;
public Godot.Collections.Array<ConsumableItem> Items { get; private set; } = [];
public override void _Ready()
{
base._Ready();
- Player = GetParent<Player>();
+ player = GetParent<Player>();
}
public void Drop(ConsumableItem item)
{
Items.Remove(item);
- MapData data = Player.MapData;
+ MapData data = player.MapData;
data.InsertEntity(item);
data.EmitSignal(MapData.SignalName.EntityPlaced, item);
item.MapData = data;
- item.GridPosition = Player.GridPosition;
+ item.GridPosition = player.GridPosition;
MessageLogData.Instance.AddMessage($"Você descarta {item.DisplayName}.");
}
diff --git a/scripts/Entities/Actors/Player.cs b/scripts/Entities/Actors/Player.cs
index 7fd80d4..d6fedb9 100644
--- a/scripts/Entities/Actors/Player.cs
+++ b/scripts/Entities/Actors/Player.cs
@@ -9,13 +9,14 @@ namespace TheLegendOfGustav.Entities.Actors;
[GlobalClass]
public partial class Player : Actor
{
+ private PlayerDefinition definition;
+
public Player(Vector2I initialPosition, MapData map, PlayerDefinition definition) : base(initialPosition, map, definition)
{
- Definition = definition;
+ this.definition = definition;
SetDefinition(definition);
}
- private PlayerDefinition Definition { get; set; }
public Inventory Inventory { get; private set; }
public void SetDefinition(PlayerDefinition definition)
diff --git a/scripts/Entities/Entity.cs b/scripts/Entities/Entity.cs
index 412bd7a..c0e026d 100644
--- a/scripts/Entities/Entity.cs
+++ b/scripts/Entities/Entity.cs
@@ -26,6 +26,12 @@ public abstract partial class Entity : Sprite2D
private bool blocksMovement;
private string displayName;
+ /// <summary>
+ /// A definição da entidade possui caracterísitcas padrões que definem
+ /// a entidade em questão.
+ /// </summary>
+ private EntityDefinition definition;
+
public Entity(Vector2I initialPosition, MapData map, EntityDefinition definition)
{
GridPosition = initialPosition;
@@ -94,12 +100,6 @@ public abstract partial class Entity : Sprite2D
}
}
- /// <summary>
- /// A definição da entidade possui caracterísitcas padrões que definem
- /// a entidade em questão.
- /// </summary>
- private EntityDefinition Definition;
-
public override void _Ready()
{
base._Ready();
@@ -118,7 +118,7 @@ public abstract partial class Entity : Sprite2D
/// <param name="definition">A definição do ator.</param>
public virtual void SetDefinition(EntityDefinition definition)
{
- Definition = definition;
+ this.definition = definition;
BlocksMovement = definition.blocksMovement;
DisplayName = definition.name;
Type = definition.Type;
diff --git a/scripts/Entities/Items/HealingConsumable.cs b/scripts/Entities/Items/HealingConsumable.cs
index 32f76a6..85377d3 100644
--- a/scripts/Entities/Items/HealingConsumable.cs
+++ b/scripts/Entities/Items/HealingConsumable.cs
@@ -8,7 +8,7 @@ namespace TheLegendOfGustav.Entities.Items;
public partial class HealingConsumable(Vector2I initialPosition, MapData map, HealingConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition)
{
- private HealingConsumableDefinition Definition { get; set; } = definition;
+ private HealingConsumableDefinition definition = definition;
public float HealingPercentage { get; private set; } = definition.healingPercentage;
public override bool Activate(ItemAction action)
diff --git a/scripts/Entities/Items/ScrollConsumable.cs b/scripts/Entities/Items/ScrollConsumable.cs
index 7dc8e48..2869deb 100644
--- a/scripts/Entities/Items/ScrollConsumable.cs
+++ b/scripts/Entities/Items/ScrollConsumable.cs
@@ -17,8 +17,6 @@ namespace TheLegendOfGustav.Entities.Items;
/// <param name="definition">Definição do item.</param>
public partial class ScrollConsumable(Vector2I initialPosition, MapData map, ScrollConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition)
{
- public SpellResource Spell { get; private set; } = definition.Spell;
-
/// <summary>
/// O pergaminho só pode ser usado uma única vez.
/// Alguns feitiços precisam de um alvo, o que significa que
@@ -41,6 +39,8 @@ public partial class ScrollConsumable(Vector2I initialPosition, MapData map, Scr
/// </summary>
private SignalBus.PlayerSpellCastEventHandler bindSignal = null;
+ public SpellResource Spell { get; private set; } = definition.Spell;
+
public override bool Activate(ItemAction action)
{
if (awaitingTermination)
diff --git a/scripts/GUI/Details.cs b/scripts/GUI/Details.cs
index 3ead3a9..42268b1 100644
--- a/scripts/GUI/Details.cs
+++ b/scripts/GUI/Details.cs
@@ -11,10 +11,10 @@ public partial class Details : CanvasLayer
[Export]
private Map.Map map;
- private VBoxContainer EntityNames { get; set; }
- private Godot.Collections.Array<Entity> Entities { get; set; } = [];
+ private VBoxContainer entityNames;
+ private Godot.Collections.Array<Entity> entities= [];
- private Godot.Collections.Array<Label> ActorsLabel { get; set; } = [];
+ private Godot.Collections.Array<Label> actorsLabel = [];
private SignalBus.EnterInspectionModeEventHandler enterLambda;
private SignalBus.ExitInspectionModeEventHandler exitLambda;
@@ -22,7 +22,7 @@ public partial class Details : CanvasLayer
public override void _Ready()
{
base._Ready();
- EntityNames = GetNode<VBoxContainer>("HBoxContainer/PanelContainer/ScrollContainer/Entities");
+ entityNames = GetNode<VBoxContainer>("HBoxContainer/PanelContainer/ScrollContainer/Entities");
enterLambda = () => Visible = true;
exitLambda = () => Visible = false;
@@ -34,7 +34,7 @@ public partial class Details : CanvasLayer
public void OnInspectorWalk(Vector2I pos)
{
MapData mapData = map.MapData;
- Entities = mapData.GetEntitiesAtPosition(pos);
+ entities = mapData.GetEntitiesAtPosition(pos);
UpdateLabels();
}
@@ -57,14 +57,14 @@ public partial class Details : CanvasLayer
private void UpdateLabels()
{
- foreach (Label label in ActorsLabel)
+ foreach (Label label in actorsLabel)
{
label.QueueFree();
}
- ActorsLabel.Clear();
+ actorsLabel.Clear();
- foreach (Entity entity in Entities)
+ foreach (Entity entity in entities)
{
Label label = new()
{
@@ -72,8 +72,8 @@ public partial class Details : CanvasLayer
LabelSettings = lblSettings
};
- ActorsLabel.Add(label);
- EntityNames.AddChild(label);
+ actorsLabel.Add(label);
+ entityNames.AddChild(label);
}
}
}
diff --git a/scripts/GUI/Hud.cs b/scripts/GUI/Hud.cs
index 227ca32..a1511b8 100644
--- a/scripts/GUI/Hud.cs
+++ b/scripts/GUI/Hud.cs
@@ -3,7 +3,7 @@ using Godot;
namespace TheLegendOfGustav.GUI;
-public partial class Hud : Node
+public partial class Hud : CanvasLayer
{
private TextureProgressBar hpBar;
private TextureProgressBar mpBar;
diff --git a/scripts/GUI/InventoryMenu.cs b/scripts/GUI/InventoryMenu.cs
index 5bac62b..dd8e133 100644
--- a/scripts/GUI/InventoryMenu.cs
+++ b/scripts/GUI/InventoryMenu.cs
@@ -8,18 +8,18 @@ public partial class InventoryMenu : CanvasLayer
{
private static readonly PackedScene itemMenuEntryScene = GD.Load<PackedScene>("res://scenes/GUI/item_menu_entry.tscn");
+ private VBoxContainer itemsNode;
+
[Signal]
public delegate void ItemSelectedEventHandler(ConsumableItem item);
[Signal]
public delegate void ItemDropEventHandler(ConsumableItem item);
- private VBoxContainer ItemsNode { get; set; }
-
public override void _Ready()
{
base._Ready();
- ItemsNode = GetNode<VBoxContainer>("CenterContainer/PanelContainer/VBoxContainer/Items");
+ itemsNode = GetNode<VBoxContainer>("CenterContainer/PanelContainer/VBoxContainer/Items");
Hide();
}
@@ -55,7 +55,7 @@ public partial class InventoryMenu : CanvasLayer
ItemMenuEntry itemEntry = itemMenuEntryScene.Instantiate<ItemMenuEntry>();
- ItemsNode.AddChild(itemEntry);
+ itemsNode.AddChild(itemEntry);
itemEntry.Initialize(item, shortcut);
itemEntry.Activate += OnActivate;
itemEntry.Drop += OnDrop;
diff --git a/scripts/GUI/ItemMenuEntry.cs b/scripts/GUI/ItemMenuEntry.cs
index 7070b21..6f18bd9 100644
--- a/scripts/GUI/ItemMenuEntry.cs
+++ b/scripts/GUI/ItemMenuEntry.cs
@@ -6,39 +6,39 @@ namespace TheLegendOfGustav.GUI;
public partial class ItemMenuEntry : HBoxContainer
{
+ private TextureRect icon;
+ private Label shortcutLabel;
+ private Label nameLabel;
+ private Button activateBtn;
+ private Button dropBtn;
+ private ConsumableItem item;
+
[Signal]
public delegate void ActivateEventHandler(ConsumableItem Item);
[Signal]
public delegate void DropEventHandler(ConsumableItem Item);
- private TextureRect Icon { get; set; }
- private Label ShortcutLabel { get; set; }
- private Label NameLabel { get; set; }
- private Button ActivateBtn { get; set; }
- private Button DropBtn { get; set; }
- private ConsumableItem Item { get; set; }
-
public override void _Ready()
{
base._Ready();
- Icon = GetNode<TextureRect>("Icon");
- ShortcutLabel = GetNode<Label>("Shortcut");
- NameLabel = GetNode<Label>("ItemName");
- ActivateBtn = GetNode<Button>("ActivateBtn");
- DropBtn = GetNode<Button>("DropButton");
+ icon = GetNode<TextureRect>("Icon");
+ shortcutLabel = GetNode<Label>("Shortcut");
+ nameLabel = GetNode<Label>("ItemName");
+ activateBtn = GetNode<Button>("ActivateBtn");
+ dropBtn = GetNode<Button>("DropButton");
- ActivateBtn.Pressed += () => EmitSignal(SignalName.Activate, Item);
- DropBtn.Pressed += () => EmitSignal(SignalName.Drop, Item);
+ activateBtn.Pressed += () => EmitSignal(SignalName.Activate, item);
+ dropBtn.Pressed += () => EmitSignal(SignalName.Drop, item);
}
public void Initialize(ConsumableItem item, char? shortcut)
{
- Item = item;
- NameLabel.Text = item.DisplayName;
+ this.item = item;
+ nameLabel.Text = item.DisplayName;
if (shortcut != null)
{
- ShortcutLabel.Text = $"{shortcut}";
+ shortcutLabel.Text = $"{shortcut}";
int index = (int)shortcut - 'a';
@@ -63,13 +63,13 @@ public partial class ItemMenuEntry : HBoxContainer
Events = [dropEvent]
};
- ActivateBtn.Shortcut = shortie;
- DropBtn.Shortcut = dropperino;
+ activateBtn.Shortcut = shortie;
+ dropBtn.Shortcut = dropperino;
}
else
{
- ShortcutLabel.Text = "";
+ shortcutLabel.Text = "";
}
- Icon.Texture = item.Texture;
+ icon.Texture = item.Texture;
}
}
diff --git a/scripts/GUI/MainMenu.cs b/scripts/GUI/MainMenu.cs
index 4d89b36..15ccc33 100644
--- a/scripts/GUI/MainMenu.cs
+++ b/scripts/GUI/MainMenu.cs
@@ -4,9 +4,9 @@ namespace TheLegendOfGustav.GUI;
public partial class MainMenu : Control
{
- private Button NewGameButton;
- private Button LoadGameButton;
- private Button QuitButton;
+ private Button newGameButton;
+ private Button loadGameButton;
+ private Button quitButton;
[Signal]
public delegate void GameRequestEventHandler(bool load);
@@ -15,17 +15,17 @@ public partial class MainMenu : Control
{
base._Ready();
- NewGameButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/neogame");
- LoadGameButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/continue");
- QuitButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/quit");
+ newGameButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/neogame");
+ loadGameButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/continue");
+ quitButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/quit");
- NewGameButton.Pressed += OnNewGameButtonPressed;
- LoadGameButton.Pressed += OnLoadGameButtonPressed;
- QuitButton.Pressed += OnQuitButtonPressed;
+ newGameButton.Pressed += OnNewGameButtonPressed;
+ loadGameButton.Pressed += OnLoadGameButtonPressed;
+ quitButton.Pressed += OnQuitButtonPressed;
- NewGameButton.GrabFocus();
+ newGameButton.GrabFocus();
bool hasSaveFile = FileAccess.FileExists("user://save.dat");
- LoadGameButton.Disabled = !hasSaveFile;
+ loadGameButton.Disabled = !hasSaveFile;
}
private void OnNewGameButtonPressed()
diff --git a/scripts/GUI/MessageLog.cs b/scripts/GUI/MessageLog.cs
index c83879a..2a69860 100644
--- a/scripts/GUI/MessageLog.cs
+++ b/scripts/GUI/MessageLog.cs
@@ -6,13 +6,13 @@ namespace TheLegendOfGustav.GUI;
public partial class MessageLog : ScrollContainer
{
- private VBoxContainer MessageList { get; set; }
+ private VBoxContainer messageList;
private MessageLogData.messageSentEventHandler joinSignal;
public override void _Ready()
{
base._Ready();
- MessageList = GetNode<VBoxContainer>("MessageList");
+ messageList = GetNode<VBoxContainer>("MessageList");
foreach (Message msg in MessageLogData.Instance.Messages)
{
@@ -38,7 +38,7 @@ public partial class MessageLog : ScrollContainer
private async Task AddMessageAsync(Message message)
{
- MessageList.AddChild(message);
+ messageList.AddChild(message);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
EnsureControlVisible(message);
}
diff --git a/scripts/Game.cs b/scripts/Game.cs
index 3bb1b83..f03aa20 100644
--- a/scripts/Game.cs
+++ b/scripts/Game.cs
@@ -21,23 +21,23 @@ public partial class Game : Node
/// <summary>
/// O jogo possui o mapa.
/// </summary>
- private Map.Map Map { get; set; }
+ private Map.Map map;
/// <summary>
/// Objeto para obter input do usuário.
/// </summary>
- private InputHandler InputHandler { get; set; }
+ private InputHandler inputHandler;
/// <summary>
/// Gerenciador de turnos
/// </summary>
- private TurnManager TurnManager { get; set; }
+ private TurnManager turnManager;
private Hud hud;
+ private SignalBus.EscapeRequestedEventHandler escapeLambda;
+
[Signal]
public delegate void MainMenuRequestedEventHandler();
- private SignalBus.EscapeRequestedEventHandler escapeLambda;
-
public override void _Ready()
{
base._Ready();
@@ -45,9 +45,9 @@ public partial class Game : Node
escapeLambda = () => EmitSignal(SignalName.MainMenuRequested);
SignalBus.Instance.EscapeRequested += escapeLambda;
- Map = GetNode<Map.Map>("Map");
+ map = GetNode<Map.Map>("Map");
- InputHandler = GetNode<InputHandler>("InputHandler");
+ inputHandler = GetNode<InputHandler>("InputHandler");
hud = GetNode<Hud>("HUD");
// O jogador é criado pelo jogo.
@@ -56,15 +56,15 @@ public partial class Game : Node
RemoveChild(camera);
player.HealthChanged += (int hp, int maxHp) => hud.OnHealthChanged(hp, maxHp);
player.ManaChanged += hud.OnManaChanged;
- player.Died += () => InputHandler.SetInputHandler(InputHandlers.GameOver);
+ player.Died += () => inputHandler.SetInputHandler(InputHandlers.GameOver);
player.AddChild(camera);
- Map.Generate(player);
+ map.Generate(player);
- Map.UpdateFOV(player.GridPosition);
+ map.UpdateFOV(player.GridPosition);
- TurnManager = new(Map);
+ turnManager = new(map);
MessageLogData.Instance.AddMessage("Boa sorte!");
}
@@ -90,18 +90,18 @@ public partial class Game : Node
{
base._PhysicsProcess(delta);
- Player player = Map.MapData.Player;
+ Player player = map.MapData.Player;
// Pegamos uma ação do usuário
- Action action = InputHandler.GetAction(player);
+ Action action = inputHandler.GetAction(player);
if (action != null)
{
- TurnManager.InsertPlayerAction(action);
+ turnManager.InsertPlayerAction(action);
}
// Computamos um turno.
- TurnManager.Tick();
+ turnManager.Tick();
}
}
diff --git a/scripts/InputHandling/InputHandler.cs b/scripts/InputHandling/InputHandler.cs
index 3c39587..e230a01 100644
--- a/scripts/InputHandling/InputHandler.cs
+++ b/scripts/InputHandling/InputHandler.cs
@@ -23,38 +23,38 @@ public enum InputHandlers
public partial class InputHandler : Node
{
[Export]
- private InputHandlers StartingInputHandler { get; set; }
+ private InputHandlers startingInputHandler;
- private Godot.Collections.Dictionary<InputHandlers, BaseInputHandler> InputHandlerDict { get; set; } = [];
+ private Godot.Collections.Dictionary<InputHandlers, BaseInputHandler> inputHandlerDict = [];
- private BaseInputHandler SelectedInputHandler { get; set; }
+ private BaseInputHandler selectedInputHandler;
public override void _Ready()
{
base._Ready();
// Controles para quando o jogador está vivo e jogando normalmente.
- InputHandlerDict.Add(InputHandlers.MainGame, GetNode<MainGameInputHandler>("MainGameInputHandler"));
+ inputHandlerDict.Add(InputHandlers.MainGame, GetNode<MainGameInputHandler>("MainGameInputHandler"));
// Controles para quando o jogador está morto.
- InputHandlerDict.Add(InputHandlers.GameOver, GetNode<GameOverInputHandler>("GameOverInputHandler"));
+ inputHandlerDict.Add(InputHandlers.GameOver, GetNode<GameOverInputHandler>("GameOverInputHandler"));
// Controles para observar o cenário
- InputHandlerDict.Add(InputHandlers.Inspect, GetNode<InspectInputHandler>("InspectInputHandler"));
+ inputHandlerDict.Add(InputHandlers.Inspect, GetNode<InspectInputHandler>("InspectInputHandler"));
// Controles para pegar um item do chão.
- InputHandlerDict.Add(InputHandlers.Pickup, GetNode<PickupInputHandler>("PickupInputHandler"));
+ inputHandlerDict.Add(InputHandlers.Pickup, GetNode<PickupInputHandler>("PickupInputHandler"));
// Controles para quando o inventário for aberto.
- InputHandlerDict.Add(InputHandlers.Inventory, GetNode<InventoryInputHandler>("InventoryInputHandler"));
+ inputHandlerDict.Add(InputHandlers.Inventory, GetNode<InventoryInputHandler>("InventoryInputHandler"));
// Controles para quando o jogador precisar escolher um alvo de feitiço.
- InputHandlerDict.Add(InputHandlers.CastSpell, GetNode<CastSpellInputHandler>("CastSpellInputHandler"));
+ inputHandlerDict.Add(InputHandlers.CastSpell, GetNode<CastSpellInputHandler>("CastSpellInputHandler"));
// Controles para quando o menu de feitiços for aberto.
- InputHandlerDict.Add(InputHandlers.SpellMenu, GetNode<SpellMenuInputHandler>("SpellMenuInputHandler"));
+ inputHandlerDict.Add(InputHandlers.SpellMenu, GetNode<SpellMenuInputHandler>("SpellMenuInputHandler"));
- SetInputHandler(StartingInputHandler);
+ SetInputHandler(startingInputHandler);
SignalBus.Instance.CommandInputHandler += SetInputHandler;
}
public Action GetAction(Player player)
{
- return SelectedInputHandler.GetAction(player);
+ return selectedInputHandler.GetAction(player);
}
public override void _Notification(int what)
@@ -73,8 +73,8 @@ public partial class InputHandler : Node
/// <param name="inputhandler">Estado do jogo.</param>
public void SetInputHandler(InputHandlers inputhandler)
{
- SelectedInputHandler?.Exit();
- SelectedInputHandler = InputHandlerDict[inputhandler];
- SelectedInputHandler.Enter();
+ selectedInputHandler?.Exit();
+ selectedInputHandler = inputHandlerDict[inputhandler];
+ selectedInputHandler.Enter();
}
}
diff --git a/scripts/InputHandling/InspectInputHandler.cs b/scripts/InputHandling/InspectInputHandler.cs
index 90734f9..6e13c2f 100644
--- a/scripts/InputHandling/InspectInputHandler.cs
+++ b/scripts/InputHandling/InspectInputHandler.cs
@@ -10,7 +10,7 @@ namespace TheLegendOfGustav.InputHandling;
/// </summary>
public partial class InspectInputHandler : BaseInputHandler
{
- private static readonly PackedScene InspectorScene = GD.Load<PackedScene>("res://scenes/Inspector.tscn");
+ private static readonly PackedScene inspectorScene = GD.Load<PackedScene>("res://scenes/Inspector.tscn");
private static readonly Godot.Collections.Dictionary<string, Vector2I> directions = new()
{
@@ -28,23 +28,23 @@ public partial class InspectInputHandler : BaseInputHandler
/// Preciso disso
/// </summary>
[Export]
- private Map.Map Map { get; set; }
+ private Map.Map map;
- private Inspector Inspector { get; set; }
+ private Inspector inspector;
public override void Enter()
{
SignalBus.Instance.EmitSignal(SignalBus.SignalName.EnterInspectionMode);
- Inspector = InspectorScene.Instantiate<Inspector>();
+ inspector = inspectorScene.Instantiate<Inspector>();
- Inspector.GridPosition = Map.MapData.Player.GridPosition;
+ inspector.GridPosition = map.MapData.Player.GridPosition;
- Map.AddChild(Inspector);
+ map.AddChild(inspector);
}
public override void Exit()
{
- Inspector.QueueFree();
+ inspector.QueueFree();
SignalBus.Instance.EmitSignal(SignalBus.SignalName.ExitInspectionMode);
}
@@ -56,7 +56,7 @@ public partial class InspectInputHandler : BaseInputHandler
{
if (Input.IsActionJustPressed(direction.Key))
{
- Inspector.Walk(direction.Value);
+ inspector.Walk(direction.Value);
}
}
diff --git a/scripts/InputHandling/InventoryInputHandler.cs b/scripts/InputHandling/InventoryInputHandler.cs
index 390e545..1eb7f3a 100644
--- a/scripts/InputHandling/InventoryInputHandler.cs
+++ b/scripts/InputHandling/InventoryInputHandler.cs
@@ -12,41 +12,41 @@ public partial class InventoryInputHandler : BaseInputHandler
[Export]
- private Map.Map Map { get; set; }
+ private Map.Map map;
- private InventoryMenu InventoryMenu { get; set; }
- private ConsumableItem ActivationItem { get; set; } = null;
- private ConsumableItem DropItem { get; set; } = null;
+ private InventoryMenu inventoryMenu;
+ private ConsumableItem activationItem = null;
+ private ConsumableItem dropItem = null;
public override void Enter()
{
- InventoryMenu = inventoryScene.Instantiate<InventoryMenu>();
- Map.MapData.Player.AddChild(InventoryMenu);
- InventoryMenu.Initialize(Map.MapData.Player.Inventory);
- InventoryMenu.ItemSelected += OnItemActivate;
- InventoryMenu.ItemDrop += OnItemDrop;
+ inventoryMenu = inventoryScene.Instantiate<InventoryMenu>();
+ map.MapData.Player.AddChild(inventoryMenu);
+ inventoryMenu.Initialize(map.MapData.Player.Inventory);
+ inventoryMenu.ItemSelected += OnItemActivate;
+ inventoryMenu.ItemDrop += OnItemDrop;
}
public override void Exit()
{
- ActivationItem = null;
- DropItem = null;
- InventoryMenu.QueueFree();
+ activationItem = null;
+ dropItem = null;
+ inventoryMenu.QueueFree();
}
public override Action GetAction(Player player)
{
Action action = null;
- if (ActivationItem != null)
+ if (activationItem != null)
{
- action = new ItemAction(player, ActivationItem);
+ action = new ItemAction(player, activationItem);
Close();
}
- if (DropItem != null)
+ if (dropItem != null)
{
- action = new DropAction(player, DropItem);
+ action = new DropAction(player, dropItem);
Close();
}
@@ -65,11 +65,11 @@ public partial class InventoryInputHandler : BaseInputHandler
private void OnItemActivate(ConsumableItem item)
{
- ActivationItem = item;
+ activationItem = item;
}
private void OnItemDrop(ConsumableItem item)
{
- DropItem = item;
+ dropItem = item;
}
} \ No newline at end of file
diff --git a/scripts/Magic/DamageEffect.cs b/scripts/Magic/DamageEffect.cs
index c0d8d4e..211a03a 100644
--- a/scripts/Magic/DamageEffect.cs
+++ b/scripts/Magic/DamageEffect.cs
@@ -20,7 +20,7 @@ public partial class DamageEffect : SpellEffect
}
if (damageDealt <= 0) {
- MessageLogData.Instance.AddMessage($"{target.DisplayName} resite o ataque mágico de {caster.DisplayName}");
+ MessageLogData.Instance.AddMessage($"{target.DisplayName} resiste o ataque mágico de {caster.DisplayName}");
}
else {
MessageLogData.Instance.AddMessage($"{caster.DisplayName} aplica {damageDealt} de dano mágico em {target.DisplayName}");
diff --git a/scripts/Map/DungeonGenerator.cs b/scripts/Map/DungeonGenerator.cs
index f2f00a9..7dee0b4 100644
--- a/scripts/Map/DungeonGenerator.cs
+++ b/scripts/Map/DungeonGenerator.cs
@@ -26,61 +26,60 @@ public partial class DungeonGenerator : Node
GD.Load<ScrollConsumableDefinition>("res://assets/definitions/Items/mana_bolt_scroll.tres"),
GD.Load<GrimoireConsumableDefinition>("res://assets/definitions/Items/mana_bolt_grimoire.tres")
];
- #endregion
- #region Properties
/// <summary>
/// Dimensões do mapa a ser criado.
/// </summary>
[ExportCategory("Dimension")]
[Export]
- private int Width { get; set; } = 80;
+ private int width = 80;
[Export]
- private int Height { get; set; } = 60;
+ private int height = 60;
/// <summary>
- /// Gerador de números aleatórios
- /// </summary>
- [ExportCategory("RNG")]
- private RandomNumberGenerator Rng { get; set; } = new();
- /// <summary>
/// Qual seed utilizar.
/// </summary>
[Export]
- private ulong Seed { get; set; }
+ private ulong seed;
/// <summary>
/// Se será utilizada a nossa seed ou a seed padrão da classe RandomNumberGenerator.
/// </summary>
[Export]
- private bool UseSeed { get; set; } = true;
+ private bool useSeed = true;
/// <summary>
/// Quantas iterações do algoritmo chamar.
/// </summary>
[Export]
- private int Iterations { get; set; } = 3;
+ private int iterations = 3;
+
+ /// <summary>
+ /// Gerador de números aleatórios
+ /// </summary>
+ [ExportCategory("RNG")]
+ private RandomNumberGenerator rng = new();
/// <summary>
/// Quantidade máxima de inimigos por sala.
/// </summary>
[ExportCategory("Monster RNG")]
[Export]
- private int MaxMonsterPerRoom { get; set; } = 2;
+ private int maxMonstersPerRoom = 2;
/// <summary>
/// Quantidade máxima de itens por sala.
/// </summary>
[ExportCategory("Loot RNG")]
[Export]
- private int MaxItemsPerRoom { get; set; } = 2;
+ private int maxItemsPerRoom = 2;
#endregion
#region Methods
public override void _Ready()
{
base._Ready();
- if (UseSeed)
+ if (useSeed)
{
- Rng.Seed = Seed;
+ rng.Seed = seed;
}
}
@@ -93,13 +92,13 @@ public partial class DungeonGenerator : Node
/// <returns>O mapa gerado.</returns>
public MapData GenerateDungeon(Player player)
{
- MapData data = new MapData(Width, Height, player);
+ MapData data = new MapData(width, height, player);
// Divisão mestre que engloba o mapa inteiro.
- MapDivision root = new MapDivision(0, 0, Width, Height);
+ MapDivision root = new MapDivision(0, 0, width, height);
// Chama o algoritmo para dividir o mapa.
- root.Split(Iterations, Rng);
+ root.Split(iterations, rng);
bool first = true;
@@ -113,10 +112,10 @@ public partial class DungeonGenerator : Node
// A sala não pode oculpar a divisão inteira, senão não haveriam paredes.
room = room.GrowIndividual(
- -Rng.RandiRange(1, 2),
- -Rng.RandiRange(1, 2),
- -Rng.RandiRange(1, 2),
- -Rng.RandiRange(1, 2)
+ -rng.RandiRange(1, 2),
+ -rng.RandiRange(1, 2),
+ -rng.RandiRange(1, 2),
+ -rng.RandiRange(1, 2)
);
// De fato cria a sala.
@@ -236,16 +235,16 @@ public partial class DungeonGenerator : Node
private void PlaceEntities(MapData data, Rect2I room)
{
// Define quantos monstros serão colocados na sala
- int monsterAmount = Rng.RandiRange(0, MaxMonsterPerRoom);
+ int monsterAmount = rng.RandiRange(0, maxMonstersPerRoom);
// Define quantos itens serão colocados na sala.
- int itemAmount = Rng.RandiRange(0, MaxItemsPerRoom);
+ int itemAmount = rng.RandiRange(0, maxItemsPerRoom);
for (int i = 0; i < monsterAmount; i++)
{
// Escolhe um lugar aleatório na sala.
Vector2I position = new(
- Rng.RandiRange(room.Position.X, room.End.X - 1),
- Rng.RandiRange(room.Position.Y, room.End.Y - 1)
+ rng.RandiRange(room.Position.X, room.End.X - 1),
+ rng.RandiRange(room.Position.Y, room.End.Y - 1)
);
// Só podemos colocar um ator por ponto no espaço.
@@ -272,8 +271,8 @@ public partial class DungeonGenerator : Node
{
// Escolhe um lugar aleatório na sala.
Vector2I position = new(
- Rng.RandiRange(room.Position.X, room.End.X - 1),
- Rng.RandiRange(room.Position.Y, room.End.Y - 1)
+ rng.RandiRange(room.Position.X, room.End.X - 1),
+ rng.RandiRange(room.Position.Y, room.End.Y - 1)
);
bool canPlace = true;
diff --git a/scripts/Map/Map.cs b/scripts/Map/Map.cs
index 9117bc5..8521797 100644
--- a/scripts/Map/Map.cs
+++ b/scripts/Map/Map.cs
@@ -10,34 +10,34 @@ namespace TheLegendOfGustav.Map;
public partial class Map : Node2D
{
/// <summary>
- /// Dados do mapa.
- /// </summary>
- public MapData MapData { get; private set; }
-
- /// <summary>
/// raio de alcance da visão do jogador.
/// </summary>
[Export]
- private int FovRadius { get; set; } = 12;
+ private int fovRadius = 12;
+
+ private FieldOfView fieldOfView;
+
+ private Node2D tilesNode;
+ private Node2D entitiesNode;
/// <summary>
/// Gerador de mapas.
/// </summary>
- private DungeonGenerator Generator { get; set; }
-
- FieldOfView FieldOfView { get; set; }
-
- private Node2D TilesNode { get; set; }
- private Node2D EntitiesNode { get; set; }
+ private DungeonGenerator generator;
+ /// <summary>
+ /// Dados do mapa.
+ /// </summary>
+ public MapData MapData { get; private set; }
+
public override void _Ready()
{
base._Ready();
// Começamos obtendo nós relevantes para o mapa.
- Generator = GetNode<DungeonGenerator>("Generator");
- FieldOfView = GetNode<FieldOfView>("FieldOfView");
- TilesNode = GetNode<Node2D>("Tiles");
- EntitiesNode = GetNode<Node2D>("Entities");
+ generator = GetNode<DungeonGenerator>("Generator");
+ fieldOfView = GetNode<FieldOfView>("FieldOfView");
+ tilesNode = GetNode<Node2D>("Tiles");
+ entitiesNode = GetNode<Node2D>("Entities");
}
/// <summary>
@@ -46,7 +46,7 @@ public partial class Map : Node2D
/// <param name="player">O gerador de mapas precisa do jogador.</param>
public void Generate(Player player)
{
- MapData = Generator.GenerateDungeon(player);
+ MapData = generator.GenerateDungeon(player);
MapData.EntityPlaced += OnEntityPlaced;
@@ -60,7 +60,7 @@ public partial class Map : Node2D
/// <param name="pos">Centro de visão, normalmente é a posição do jogador.</param>
public void UpdateFOV(Vector2I pos)
{
- FieldOfView.UpdateFOV(MapData, pos, FovRadius);
+ fieldOfView.UpdateFOV(MapData, pos, fovRadius);
// Esconde ou revela entidades com base no campo de visão.
foreach (Entity entity in MapData.Entities)
{
@@ -76,7 +76,7 @@ public partial class Map : Node2D
{
foreach (Tile tile in MapData.Tiles)
{
- TilesNode.AddChild(tile);
+ tilesNode.AddChild(tile);
}
}
@@ -87,12 +87,12 @@ public partial class Map : Node2D
{
foreach (Entity entity in MapData.Entities)
{
- EntitiesNode.AddChild(entity);
+ entitiesNode.AddChild(entity);
}
}
private void OnEntityPlaced(Entity entity)
{
- EntitiesNode.AddChild(entity);
+ entitiesNode.AddChild(entity);
}
}
diff --git a/scripts/Map/MapData.cs b/scripts/Map/MapData.cs
index 3365380..699295e 100644
--- a/scripts/Map/MapData.cs
+++ b/scripts/Map/MapData.cs
@@ -19,7 +19,7 @@ public partial class MapData : RefCounted
/// Peso do ator no pathfinder.
/// A IA irá evitar de passar por espaços com peso alto.
/// </summary>
- private static readonly float EntityWeight = 10.0f;
+ private static readonly float entityWeight = 10.0f;
#endregion
#region Constructor
@@ -138,7 +138,7 @@ public partial class MapData : RefCounted
/// <param name="entity">A entidade em questão.</param>
public void RegisterBlockingEntity(Entity entity)
{
- Pathfinder.SetPointWeightScale(entity.GridPosition, EntityWeight);
+ Pathfinder.SetPointWeightScale(entity.GridPosition, entityWeight);
}
/// <summary>
diff --git a/scripts/Map/Tile.cs b/scripts/Map/Tile.cs
index e721fca..488d124 100644
--- a/scripts/Map/Tile.cs
+++ b/scripts/Map/Tile.cs
@@ -13,7 +13,12 @@ public partial class Tile : Sprite2D
{
private bool isExplored = false;
private bool isInView = false;
-
+
+ /// <summary>
+ /// A definição do tile carrega seus valores padrão.
+ /// </summary>
+ private TileDefinition definition;
+
public Tile(Vector2I pos, TileDefinition definition)
{
// Tile herda da classe Sprite2D.
@@ -36,10 +41,7 @@ public partial class Tile : Sprite2D
/// </summary>
public bool IsTransparent { get; private set; }
- /// <summary>
- /// A definição do tile carrega seus valores padrão.
- /// </summary>
- private TileDefinition Definition { get; set; }
+
/// <summary>
/// Se o jogador já viu este tile antes.
/// Tiles não descobertos são invisíveis.
@@ -67,7 +69,7 @@ public partial class Tile : Sprite2D
set
{
isInView = value;
- Modulate = isInView ? Definition.LitColor : Definition.DarkColor;
+ Modulate = isInView ? definition.LitColor : definition.DarkColor;
if (IsInView && !IsExplored)
{
IsExplored = true;
@@ -81,7 +83,7 @@ public partial class Tile : Sprite2D
/// <param name="definition">Definição do tile.</param>
public void SetDefinition(TileDefinition definition)
{
- Definition = definition;
+ this.definition = definition;
Modulate = definition.DarkColor;
Texture = definition.Texture;
IsWalkable = definition.IsWalkable;
diff --git a/scripts/Time/TurnManager.cs b/scripts/Time/TurnManager.cs
index e8f2db9..3d55fbb 100644
--- a/scripts/Time/TurnManager.cs
+++ b/scripts/Time/TurnManager.cs
@@ -12,16 +12,20 @@ namespace TheLegendOfGustav.Time;
/// </summary>
public partial class TurnManager(Map.Map map) : RefCounted
{
- public int TurnCount { get; private set; } = 0;
- private Map.Map Map { get; set; } = map;
- private MapData Map_Data { get => Map.MapData; }
- private Player Player { get => Map_Data.Player; }
-
+ private Map.Map map = map;
/// <summary>
/// As ações do jogador ficam em uma fila e são executadas quando
/// possível dentro das regras do senhor do tempo.
/// </summary>
- private Godot.Collections.Array<Action> PlayerActionQueue { get; set; } = [];
+ private Godot.Collections.Array<Action> playerActionQueue = [];
+
+ /// <summary>
+ /// A quantidade de turnos que se passaram.
+ /// </summary>
+ public int TurnCount { get; private set; } = 0;
+
+ private MapData Map_Data { get => map.MapData; }
+ private Player Player { get => Map_Data.Player; }
/// <summary>
/// Insere uma ação na fila de ações do jogador.
@@ -29,7 +33,7 @@ public partial class TurnManager(Map.Map map) : RefCounted
/// <param name="playerAction"></param>
public void InsertPlayerAction(Action playerAction)
{
- PlayerActionQueue.Add(playerAction);
+ playerActionQueue.Add(playerAction);
}
/// <summary>
@@ -44,7 +48,7 @@ public partial class TurnManager(Map.Map map) : RefCounted
{
// Se o jogador puder agir mas a fila de ações estiver vazia,
// não computamos o turno.
- if (PlayerActionQueue.Count == 0 && Player.Energy > 0)
+ if (playerActionQueue.Count == 0 && Player.Energy > 0)
{
return;
}
@@ -59,10 +63,10 @@ public partial class TurnManager(Map.Map map) : RefCounted
bool actionResult = true; ;
// Primeiro executamos a ação do jogador, se ele puder.
- if (PlayerActionQueue.Count > 0 && Player.Energy > 0)
+ if (playerActionQueue.Count > 0 && Player.Energy > 0)
{
- Action action = PlayerActionQueue[0];
- PlayerActionQueue.RemoveAt(0);
+ Action action = playerActionQueue[0];
+ playerActionQueue.RemoveAt(0);
actionResult = action.Perform();
@@ -80,12 +84,12 @@ public partial class TurnManager(Map.Map map) : RefCounted
{
// Depois computamos os turnos dos outros atores.
HandleEnemyTurns();
- Map.UpdateFOV(Player.GridPosition);
+ map.UpdateFOV(Player.GridPosition);
}
// Por fim, se o jogador mudou de lugar, atualizamos seu campo de visão.
if (Player.GridPosition != previousPlayerPos)
{
- Map.UpdateFOV(Player.GridPosition);
+ map.UpdateFOV(Player.GridPosition);
}
}