diff options
Diffstat (limited to 'scripts/actors')
| -rw-r--r-- | scripts/actors/AI/HostileEnemyAI.cs | 8 | ||||
| -rw-r--r-- | scripts/actors/Actor.cs | 31 | ||||
| -rw-r--r-- | scripts/actors/ActorDefinition.cs | 2 | ||||
| -rw-r--r-- | scripts/actors/actions/Action.cs | 5 | ||||
| -rw-r--r-- | scripts/actors/actions/BumpAction.cs | 4 | ||||
| -rw-r--r-- | scripts/actors/actions/MeleeAction.cs | 1 | ||||
| -rw-r--r-- | scripts/actors/actions/MovementAction.cs | 1 | ||||
| -rw-r--r-- | scripts/actors/actions/WaitAction.cs | 1 |
8 files changed, 50 insertions, 3 deletions
diff --git a/scripts/actors/AI/HostileEnemyAI.cs b/scripts/actors/AI/HostileEnemyAI.cs index 3989004..af87360 100644 --- a/scripts/actors/AI/HostileEnemyAI.cs +++ b/scripts/actors/AI/HostileEnemyAI.cs @@ -47,6 +47,8 @@ public partial class HostileEnemyAI : BaseAI Vector2I destination = (Vector2I) path[0]; // Se tiver um outro ator no caminho, paramos o nosso turno aqui. if (body.Map_Data.GetBlockingActorAtPosition(destination) != null) { + action = new WaitAction(body); + action.Perform(); return; } @@ -55,6 +57,12 @@ public partial class HostileEnemyAI : BaseAI action.Perform(); // Podemos remover o passo do caminho. path.RemoveAt(0); + return; } + + // Senão, espere. + action = new WaitAction(body); + action.Perform(); + return; } }
\ No newline at end of file diff --git a/scripts/actors/Actor.cs b/scripts/actors/Actor.cs index 642e9fd..b651286 100644 --- a/scripts/actors/Actor.cs +++ b/scripts/actors/Actor.cs @@ -21,7 +21,36 @@ public abstract partial class Actor : Sprite2D /// Se o ator está vivo. /// </summary> public bool IsAlive { get => Hp > 0; } - + + private int energy; + /// <summary> + /// Utilizado no sistema de turnos. + /// Enquanto o ator tiver energia, ele poderá realizar turnos. + /// </summary> + public int Energy + { + get => energy; + set + { + if (value > Speed) { + energy = Speed; + } else { + energy = value; + } + } + } + /// <summary> + /// Taxa de recarga de energia. + /// </summary> + public int Speed { get => definition.Speed; } + + /// <summary> + /// Executado uma vez por turno, + /// </summary> + public void RechargeEnergy() { + Energy += Speed; + } + private Vector2I gridPosition = Vector2I.Zero; /// <summary> /// Posição do ator no mapa do jogo. Diferentemente de Position, GridPosition tem como formato diff --git a/scripts/actors/ActorDefinition.cs b/scripts/actors/ActorDefinition.cs index 7f67787..ab0160b 100644 --- a/scripts/actors/ActorDefinition.cs +++ b/scripts/actors/ActorDefinition.cs @@ -21,6 +21,8 @@ public partial class ActorDefinition : Resource // Se o ator bloqueia movimento. [Export] public bool blocksMovement = true; + [Export] + public int Speed { get; set;} = 10; // Estatísticas padrão do ator. [ExportCategory("Stats")] diff --git a/scripts/actors/actions/Action.cs b/scripts/actors/actions/Action.cs index 0320dd8..f20e262 100644 --- a/scripts/actors/actions/Action.cs +++ b/scripts/actors/actions/Action.cs @@ -11,8 +11,13 @@ public abstract partial class Action : RefCounted { /// </summary> protected Actor actor; + // O custo da ação. + protected int cost; + public Action(Actor actor) { this.actor = actor; + // Custo base, subclasses podem sobreescrever isto se quiserem. + cost = 10; } /// <summary> diff --git a/scripts/actors/actions/BumpAction.cs b/scripts/actors/actions/BumpAction.cs index 0ce7fbe..805520c 100644 --- a/scripts/actors/actions/BumpAction.cs +++ b/scripts/actors/actions/BumpAction.cs @@ -11,10 +11,10 @@ public partial class BumpAction : DirectionalAction { } + // Como esta ação inevitavelmente gera outras ações, + // não faz sentido descontar a energia do ator. public override void Perform() { - Vector2I destination = actor.GridPosition + Offset; - // Declaramos uma ação genérica. Action action; diff --git a/scripts/actors/actions/MeleeAction.cs b/scripts/actors/actions/MeleeAction.cs index c61a803..56a2dc3 100644 --- a/scripts/actors/actions/MeleeAction.cs +++ b/scripts/actors/actions/MeleeAction.cs @@ -32,6 +32,7 @@ public partial class MeleeAction : DirectionalAction attackDesc += $" mas {target.ActorName} tem músculos de aço."; } + actor.Energy -= cost; GD.Print(attackDesc); } } diff --git a/scripts/actors/actions/MovementAction.cs b/scripts/actors/actions/MovementAction.cs index b37f9ae..6cec875 100644 --- a/scripts/actors/actions/MovementAction.cs +++ b/scripts/actors/actions/MovementAction.cs @@ -18,6 +18,7 @@ public partial class MovementAction : DirectionalAction // Na maioria dos casos, essa condição nunca é verdadeira. if (GetTargetActor() != null) return; + actor.Energy -= cost; actor.Walk(Offset); } } diff --git a/scripts/actors/actions/WaitAction.cs b/scripts/actors/actions/WaitAction.cs index 4ad064a..2d3ccc2 100644 --- a/scripts/actors/actions/WaitAction.cs +++ b/scripts/actors/actions/WaitAction.cs @@ -96,6 +96,7 @@ public partial class WaitAction : Action //@@@@@@@@@@@@*====+==++=*@. @ @@* .@* @ .*#. @ @* #: -@ @@% @ -+ =*%@@= @@: @ @ +. #+ *@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@======++====+*%@@@@%%%@@@@%*+#@@@@@%#%@@#=+**=. =**+=***==*#*: :%@@@@@@@@@**=+#*==*###*=. -=**+::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@+==+==++=====++=====++=+++++++++===+++++#% +@@@* :#%= =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + actor.Energy -= cost; } |
