diff options
Diffstat (limited to 'scripts/entities/actors/Actor.cs')
| -rw-r--r-- | scripts/entities/actors/Actor.cs | 215 |
1 files changed, 0 insertions, 215 deletions
diff --git a/scripts/entities/actors/Actor.cs b/scripts/entities/actors/Actor.cs deleted file mode 100644 index 1cb1f37..0000000 --- a/scripts/entities/actors/Actor.cs +++ /dev/null @@ -1,215 +0,0 @@ -using Godot; - -/// <summary> -/// A classe de ator define um personagem no jogo. -/// </summary> -[GlobalClass] -public partial class Actor : Entity -{ - /// <summary> - /// Sinal emitido toda vez que o HP mudar. - /// </summary> - /// <param name="hp">Novo HP</param> - /// <param name="maxHp">Quantidade máxima de HP.</param> - [Signal] - public delegate void HealthChangedEventHandler(int hp, int maxHp); - - /// <summary> - /// Sinal emitido se o ator morrer. - /// </summary> - [Signal] - public delegate void DiedEventHandler(); - - - /// <summary> - /// A definição do ator possui caracterísitcas padrões que definem - /// o ator em questão. - /// </summary> - private ActorDefinition definition; - - /// <summary> - /// 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 int hp; - /// <summary> - /// HP máximo do ator. - /// </summary> - public int MaxHp { get; private set; } - /// <summary> - /// HP atual do ator. - /// </summary> - public int Hp { - get => hp; - set { - // Esta propriedade impede que o HP seja maior que o máximo. - hp = int.Clamp(value, 0, MaxHp); - EmitSignal(SignalName.HealthChanged, Hp, MaxHp); - if (hp <= 0) { - Die(); - } - } - } - - private int mp; - /// <summary> - /// Máximo de mana do ator. - /// </summary> - public int MaxMp { get; private set; } - /// <summary> - /// Mana atual do ator. - /// </summary> - public int Mp { - get => mp; - set { - mp = int.Clamp(value, 0, MaxMp); - } - } - - /// <summary> - /// Estatística de ataque - /// </summary> - public int Atk { get; private set; } - - /// <summary> - /// Estatística de defesa. - /// </summary> - public int Def { get; private set; } - - /// <summary> - /// Estatística mental. - /// </summary> - public int Men { get; private set; } - - /// <summary> - /// Move o ator para uma localização. Veja MovementAction. - /// </summary> - /// <param name="offset">Vetor que parte da posição do ator até o seu destino.</param> - public void Walk(Vector2I offset) { - // Cada ator tem um peso no sistema de pathfinding. - // Sempre que ele se mover, removemos seu peso da posição antiga - Map_Data.UnregisterBlockingEntity(this); - GridPosition += offset; - // E colocamos na próxima. - Map_Data.RegisterBlockingEntity(this); - // Este peso influencia o algoritmo de pathfinding. - // Atores evitam caminhos bloqueados. por outros atores. - } - - public Actor(Vector2I initialPosition, MapData map, ActorDefinition definition) : base(initialPosition, map, definition) { - - SetDefinition(definition); - } - - /// <summary> - /// Recupera uma quantidade de HP do ator. - /// </summary> - /// <param name="amount">HP para recuperar</param> - /// <returns>Quanto HP foi realmente recuperado.</returns> - public int Heal(int amount) { - int neoHp = Hp + amount; - - if (neoHp > MaxHp) neoHp = MaxHp; - - int recovered = neoHp - Hp; - Hp = neoHp; - return recovered; - } - - /// <summary> - /// Aplica uma definição de NPC para o ator. - /// Se o ator for um boneco de barro, este método é como um - /// sopro de vida. - /// </summary> - /// <param name="definition">A definição do ator.</param> - public virtual void SetDefinition(ActorDefinition definition) { - base.SetDefinition(definition); - this.definition = definition; - - Type = definition.Type; - - MaxHp = definition.Hp; - Hp = definition.Hp; - MaxMp = definition.Mp; - Mp = definition.Mp; - - Atk = definition.Atk; - Def = definition.Def; - Men = definition.Men; - } - - public virtual void Die() { - //⠀⠀⠀⠀⢠⣤⣤⣤⢠⣤⣤⣤⣤⣄⢀⣠⣤⣤⣄⠀⠀⠀⢀⣠⣤⣤⣄⠀⣤⣤⠀⠀⣠⣤⣤⣤⣤⣤⡄⢠⣤⣤⣤⣄⠀⠀ - //⠀⠀⠀⠀⠈⢹⣿⠉⠈⠉⣿⣿⠉⠉⢾⣿⣉⣉⠙⠀⠀⢀⣾⡟⠉⠉⣿⣧⢸⣿⡄⢠⣿⠏⣿⣿⣉⣉⡁⢸⣿⡏⢉⣿⡷⠀ - //⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⣿⠀⠀⠈⠿⠿⣿⣿⡀⠀⠸⣿⡇⠀⠀⣾⣿⠀⢿⣿⣸⡿⠀⣿⣿⠿⠿⠇⢸⣿⣿⣿⣿⠀⠀ - //⠀⠀⠀⠀⢠⣼⣿⣤⠀⠀⣿⣿⠀⠀⢷⣦⣤⣼⡿⠁⠀⠀⠹⣿⣤⣴⡿⠋⠀⠘⣿⣿⠃⠀⣿⣿⣤⣤⡄⢸⣿⡇⠙⢿⣦⡀ - //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⠀⠀⠀⠀⠀⢀⣰⣶⣶⣶⣿⣿⣿⣿⣷⣶⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⠿⠛⠛⠻⢿⣿⣿⣿⣿⣿⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⠀⠀⢀⢾⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠈⠉⠉⠉⠻⢿⢿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⠀⢠⠏⢸⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⢻⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⢀⠇⠀⠈⠿⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⢀⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⡸⠀⠀⠀⠀⠀⠀⠀⠀⡼⠛⠳⣄⡀⠀⠐⢿⣦⡀⠀⠀⠀⢠⠃⠀⣸⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⢠⠇⠀⠀⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⠉⣳⠟⠒⠻⣿⣦⡀⠀⡘⠀⢰⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⢀⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠃⢠⣄⡀⠈⠙⢿⡌⠁⠀⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠳⣄⣈⢻⡿⠃⢰⠟⠲⣼⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⡰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⡶⢴⠋⠀⠀⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⡴⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠞⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡴⢟⠒⠀⠀⠀⠀⢰⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠏⠀⠀⠈⠉⣿⠇⠀⢀⡎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠠⣤⣤⣀⢰⠏⠉⠙⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣠⠴⠢⠦⠽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⣿⣿⣿⣷⡄⣀⡀⠈⠉⠋⢹⠋⠁⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - //⠿⠿⠿⠿⠿⠦⠈⠀⠀⠀⠸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - - string deathMessage; - - if (Map_Data.Player == this) { - deathMessage = "Você morreu!"; - } else { - deathMessage = $"{DisplayName} morreu!"; - } - - MessageLogData.Instance.AddMessage(deathMessage); - - Texture = definition.deathTexture; - BlocksMovement = false; - Type = EntityType.CORPSE; - DisplayName= $"Restos mortais de {DisplayName}"; - Map_Data.UnregisterBlockingEntity(this); - EmitSignal(SignalName.Died); - } -}
\ No newline at end of file |
