From 5146895cf537dd69867da612abed5b4abaf805cd Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 18 Sep 2025 12:06:59 -0300 Subject: ME ELIMINE AAAAAAAAAAAAAAAAAAAAAAAAAAAA --- scripts/Entities/Actions/Action.cs | 32 ++++----------- scripts/Entities/Actions/DropAction.cs | 2 +- scripts/Entities/Actions/ItemAction.cs | 23 ++--------- scripts/Entities/Actions/MeleeAction.cs | 2 +- scripts/Entities/Actions/MovementAction.cs | 2 +- scripts/Entities/Actions/PickUpAction.cs | 15 ++----- scripts/Entities/Actions/SpellAction.cs | 4 +- scripts/Entities/Actions/WaitAction.cs | 2 +- scripts/Entities/Actors/AI/BaseAI.cs | 8 ++-- scripts/Entities/Actors/AI/HostileEnemyAI.cs | 32 +++++++-------- scripts/Entities/Actors/Actor.cs | 22 ++++------ scripts/Entities/Actors/ActorDefinition.cs | 2 +- scripts/Entities/Actors/Enemy.cs | 8 ++-- scripts/Entities/Actors/Inventory.cs | 8 ++-- scripts/Entities/Actors/Player.cs | 5 ++- scripts/Entities/Entity.cs | 14 +++---- scripts/Entities/Items/HealingConsumable.cs | 2 +- scripts/Entities/Items/ScrollConsumable.cs | 4 +- scripts/GUI/Details.cs | 20 ++++----- scripts/GUI/Hud.cs | 2 +- scripts/GUI/InventoryMenu.cs | 8 ++-- scripts/GUI/ItemMenuEntry.cs | 42 +++++++++---------- scripts/GUI/MainMenu.cs | 22 +++++----- scripts/GUI/MessageLog.cs | 6 +-- scripts/Game.cs | 30 +++++++------- scripts/InputHandling/InputHandler.cs | 30 +++++++------- scripts/InputHandling/InspectInputHandler.cs | 16 ++++---- scripts/InputHandling/InventoryInputHandler.cs | 36 ++++++++-------- scripts/Magic/DamageEffect.cs | 2 +- scripts/Map/DungeonGenerator.cs | 57 +++++++++++++------------- scripts/Map/Map.cs | 42 +++++++++---------- scripts/Map/MapData.cs | 4 +- scripts/Map/Tile.cs | 16 ++++---- scripts/Time/TurnManager.cs | 30 ++++++++------ 34 files changed, 254 insertions(+), 296 deletions(-) (limited to 'scripts') 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; /// public abstract partial class Action : RefCounted { - private Actor actor; - - private int cost; + /// + /// O custo da ação. + /// + protected int cost; public Action(Actor actor) { Actor = actor; // Custo base, subclasses podem sobreescrever isto se quiserem. - Cost = 10; + cost = 10; } /// /// O ator que realiza a ação. /// - public Actor Actor - { - get => actor; - private set - { - actor = value; - } - } - - /// - /// O custo da ação. - /// - protected int Cost - { - get => cost; - set - { - cost = value; - } - } + public Actor Actor { get; private set; } /// /// É conveniente ter acesso ao mapa dentro de uma ação. /// protected MapData MapData { - get => actor.MapData; + get => Actor.MapData; } /// 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. /// - 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(); + body = GetParent(); } /// @@ -42,12 +42,12 @@ public abstract partial class BaseAI : Node /// /// Destino /// Vetor com vetores, passo a passo para chegar no destino. - public Godot.Collections.Array GetPathTo(Vector2I destination) + protected Godot.Collections.Array 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 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 /// /// Caminho até a última posição conhecida do jogador. /// - private Godot.Collections.Array Path { get; set; } = []; + private Godot.Collections.Array 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; + + /// + /// A definição do ator possui caracterísitcas padrões que definem + /// o ator em questão. + /// + private ActorDefinition definition; #endregion #region Constructors @@ -77,7 +83,7 @@ public partial class Actor : Entity /// /// Taxa de recarga de energia. /// - public int Speed { get => Definition.Speed; } + public int Speed { get => definition.Speed; } /// /// HP máximo do ator. @@ -142,16 +148,6 @@ public partial class Actor : Entity /// public int MpRegenPerTurn { get; private set; } = 5; - /// - /// A definição do ator possui caracterísitcas padrões que definem - /// o ator em questão. - /// - 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; /// 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 /// public BaseAI Soul { get; private set; } - private EnemyDefinition Definition { get; set; } - /// /// 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 Items { get; private set; } = []; public override void _Ready() { base._Ready(); - Player = GetParent(); + player = GetParent(); } 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; + /// + /// A definição da entidade possui caracterísitcas padrões que definem + /// a entidade em questão. + /// + private EntityDefinition definition; + public Entity(Vector2I initialPosition, MapData map, EntityDefinition definition) { GridPosition = initialPosition; @@ -94,12 +100,6 @@ public abstract partial class Entity : Sprite2D } } - /// - /// A definição da entidade possui caracterísitcas padrões que definem - /// a entidade em questão. - /// - private EntityDefinition Definition; - public override void _Ready() { base._Ready(); @@ -118,7 +118,7 @@ public abstract partial class Entity : Sprite2D /// A definição do ator. 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; /// Definição do item. public partial class ScrollConsumable(Vector2I initialPosition, MapData map, ScrollConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition) { - public SpellResource Spell { get; private set; } = definition.Spell; - /// /// 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 /// 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 Entities { get; set; } = []; + private VBoxContainer entityNames; + private Godot.Collections.Array entities= []; - private Godot.Collections.Array public partial class InspectInputHandler : BaseInputHandler { - private static readonly PackedScene InspectorScene = GD.Load("res://scenes/Inspector.tscn"); + private static readonly PackedScene inspectorScene = GD.Load("res://scenes/Inspector.tscn"); private static readonly Godot.Collections.Dictionary directions = new() { @@ -28,23 +28,23 @@ public partial class InspectInputHandler : BaseInputHandler /// Preciso disso /// [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 = inspectorScene.Instantiate(); - 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(); - Map.MapData.Player.AddChild(InventoryMenu); - InventoryMenu.Initialize(Map.MapData.Player.Inventory); - InventoryMenu.ItemSelected += OnItemActivate; - InventoryMenu.ItemDrop += OnItemDrop; + inventoryMenu = inventoryScene.Instantiate(); + 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("res://assets/definitions/Items/mana_bolt_scroll.tres"), GD.Load("res://assets/definitions/Items/mana_bolt_grimoire.tres") ]; - #endregion - #region Properties /// /// Dimensões do mapa a ser criado. /// [ExportCategory("Dimension")] [Export] - private int Width { get; set; } = 80; + private int width = 80; [Export] - private int Height { get; set; } = 60; + private int height = 60; - /// - /// Gerador de números aleatórios - /// - [ExportCategory("RNG")] - private RandomNumberGenerator Rng { get; set; } = new(); /// /// Qual seed utilizar. /// [Export] - private ulong Seed { get; set; } + private ulong seed; /// /// Se será utilizada a nossa seed ou a seed padrão da classe RandomNumberGenerator. /// [Export] - private bool UseSeed { get; set; } = true; + private bool useSeed = true; /// /// Quantas iterações do algoritmo chamar. /// [Export] - private int Iterations { get; set; } = 3; + private int iterations = 3; + + /// + /// Gerador de números aleatórios + /// + [ExportCategory("RNG")] + private RandomNumberGenerator rng = new(); /// /// Quantidade máxima de inimigos por sala. /// [ExportCategory("Monster RNG")] [Export] - private int MaxMonsterPerRoom { get; set; } = 2; + private int maxMonstersPerRoom = 2; /// /// Quantidade máxima de itens por sala. /// [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 /// O mapa gerado. 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 @@ -9,35 +9,35 @@ namespace TheLegendOfGustav.Map; /// public partial class Map : Node2D { - /// - /// Dados do mapa. - /// - public MapData MapData { get; private set; } - /// /// raio de alcance da visão do jogador. /// [Export] - private int FovRadius { get; set; } = 12; + private int fovRadius = 12; + + private FieldOfView fieldOfView; + + private Node2D tilesNode; + private Node2D entitiesNode; /// /// Gerador de mapas. /// - private DungeonGenerator Generator { get; set; } - - FieldOfView FieldOfView { get; set; } - - private Node2D TilesNode { get; set; } - private Node2D EntitiesNode { get; set; } + private DungeonGenerator generator; + /// + /// Dados do mapa. + /// + public MapData MapData { get; private set; } + public override void _Ready() { base._Ready(); // Começamos obtendo nós relevantes para o mapa. - Generator = GetNode("Generator"); - FieldOfView = GetNode("FieldOfView"); - TilesNode = GetNode("Tiles"); - EntitiesNode = GetNode("Entities"); + generator = GetNode("Generator"); + fieldOfView = GetNode("FieldOfView"); + tilesNode = GetNode("Tiles"); + entitiesNode = GetNode("Entities"); } /// @@ -46,7 +46,7 @@ public partial class Map : Node2D /// O gerador de mapas precisa do jogador. 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 /// Centro de visão, normalmente é a posição do jogador. 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. /// - 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 /// A entidade em questão. public void RegisterBlockingEntity(Entity entity) { - Pathfinder.SetPointWeightScale(entity.GridPosition, EntityWeight); + Pathfinder.SetPointWeightScale(entity.GridPosition, entityWeight); } /// 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; - + + /// + /// A definição do tile carrega seus valores padrão. + /// + private TileDefinition definition; + public Tile(Vector2I pos, TileDefinition definition) { // Tile herda da classe Sprite2D. @@ -36,10 +41,7 @@ public partial class Tile : Sprite2D /// public bool IsTransparent { get; private set; } - /// - /// A definição do tile carrega seus valores padrão. - /// - private TileDefinition Definition { get; set; } + /// /// 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 /// Definição do tile. 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; /// 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; /// /// As ações do jogador ficam em uma fila e são executadas quando /// possível dentro das regras do senhor do tempo. /// - private Godot.Collections.Array PlayerActionQueue { get; set; } = []; + private Godot.Collections.Array playerActionQueue = []; + + /// + /// A quantidade de turnos que se passaram. + /// + public int TurnCount { get; private set; } = 0; + + private MapData Map_Data { get => map.MapData; } + private Player Player { get => Map_Data.Player; } /// /// Insere uma ação na fila de ações do jogador. @@ -29,7 +33,7 @@ public partial class TurnManager(Map.Map map) : RefCounted /// public void InsertPlayerAction(Action playerAction) { - PlayerActionQueue.Add(playerAction); + playerActionQueue.Add(playerAction); } /// @@ -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); } } -- cgit v1.2.3