summaryrefslogtreecommitdiff
path: root/scripts/entities/actors/Enemy.cs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/entities/actors/Enemy.cs')
-rw-r--r--scripts/entities/actors/Enemy.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/entities/actors/Enemy.cs b/scripts/entities/actors/Enemy.cs
new file mode 100644
index 0000000..19bcd2c
--- /dev/null
+++ b/scripts/entities/actors/Enemy.cs
@@ -0,0 +1,55 @@
+using Godot;
+using System;
+
+/// <summary>
+/// Enum das diferentes IAs disponíveis.
+/// </summary>
+public enum AIType
+{
+ None,
+ DefaultHostile
+};
+
+/// <summary>
+/// Um inimigo é uma espécie de ator que é
+/// hostil ao jogador. Inimigos são controlados por IA.
+/// </summary>
+public partial class Enemy : Actor
+{
+ /// <summary>
+ /// A alma do ator. Gera ações que são executadas todo turno.
+ /// </summary>
+ public BaseAI Soul { get; private set; }
+
+ public Enemy(Vector2I initialPosition, MapData map, EnemyDefinition definition) : base(initialPosition, map, definition)
+ {
+ SetDefinition(definition);
+ }
+
+ /// <summary>
+ /// Além de definir as características gerais de um ator,
+ /// também define qual IA utilizar.
+ /// </summary>
+ /// <param name="definition">Definição do inimigo.</param>
+ public void SetDefinition(EnemyDefinition definition)
+ {
+ // Definimos as características do ator.
+ base.SetDefinition(definition);
+
+ // Definimos qual IA utilizar.
+ switch(definition.AI) {
+ case AIType.None:
+ break;
+ case AIType.DefaultHostile:
+ Soul = new HostileEnemyAI();
+ AddChild(Soul);
+ break;
+ }
+ }
+
+ public override void Die() {
+ Soul.QueueFree();
+ Soul = null;
+ base.Die();
+ }
+}