From 5958d9c071915ab71aea5a5c08d79e88024f6c58 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 14 Sep 2025 00:14:25 -0300 Subject: The newer scolls: groundrim. --- .../Entities/Actions/ChangeInputStateAction.cs.uid | 1 + scripts/Entities/Actions/SpellAction.cs | 34 ++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 scripts/Entities/Actions/ChangeInputStateAction.cs.uid (limited to 'scripts/Entities/Actions') diff --git a/scripts/Entities/Actions/ChangeInputStateAction.cs.uid b/scripts/Entities/Actions/ChangeInputStateAction.cs.uid new file mode 100644 index 0000000..c8f6440 --- /dev/null +++ b/scripts/Entities/Actions/ChangeInputStateAction.cs.uid @@ -0,0 +1 @@ +uid://bxlakdvr1lovw diff --git a/scripts/Entities/Actions/SpellAction.cs b/scripts/Entities/Actions/SpellAction.cs index 086a52a..f8819b9 100644 --- a/scripts/Entities/Actions/SpellAction.cs +++ b/scripts/Entities/Actions/SpellAction.cs @@ -1,23 +1,45 @@ using Godot; using TheLegendOfGustav.Entities.Actors; using TheLegendOfGustav.Magic; +using TheLegendOfGustav.Utils; namespace TheLegendOfGustav.Entities.Actions; -public partial class SpellCommand(Actor actor, Vector2I offset, SpellResource spell) : DirectionalAction(actor, offset) +/// +/// Ação para quando o jogador joga um feitiço. +/// +public partial class SpellAction : DirectionalAction { - private SpellResource spell = spell; + private SpellResource spell; + + public SpellAction(Actor actor, Vector2I offset, SpellResource spell) : base(actor, offset) + { + this.spell = spell; + + Cost = 5; + } public override bool Perform() { - Actor target = null; + Actor target; - if (GetTarget() is Actor actor) + if (spell.Type == SpellType.Self) + { + target = Actor; + } + else if (GetTarget() is Actor actor) { target = actor; } + else + { + return false; + } - if (spell.Type == SpellType.Ranged && target == null) return false; + if (Grid.Distance(Actor.GridPosition, target.GridPosition) > spell.Range) + { + return false; + } if (Actor.Mp < spell.Cost) { @@ -28,6 +50,8 @@ public partial class SpellCommand(Actor actor, Vector2I offset, SpellResource sp { effect.Apply(Actor, target); } + + Actor.Energy -= Cost; return true; } } -- cgit v1.2.3