Damage calculation including elemental buff/resistance

This commit is contained in:
2024-09-04 01:24:37 -07:00
parent 9a24ebf058
commit d7a49ba974
23 changed files with 311 additions and 70 deletions

View File

@@ -8,23 +8,25 @@ namespace GameJamDungeon
public partial record State
{
[Meta, Id("enemy_logic_state_alive")]
public abstract partial record Alive : State, IGet<Input.HitByPlayer>
public abstract partial record Alive : State, IGet<Input.HitByPlayer>, IGet<Input.Killed>
{
public Transition On(in Input.HitByPlayer input)
{
var enemy = Get<IEnemy>();
var gameRepo = Get<IGameRepo>();
enemy.CurrentHP -= input.Damage;
GD.Print("Current HP: " + enemy.CurrentHP);
GD.Print($"Hit by {gameRepo.EquippedWeapon.Name}");
enemy.CurrentHP.OnNext(enemy.CurrentHP.Value - input.Damage);
GD.Print("Current HP: " + enemy.CurrentHP.Value);
Output(new Output.HitByPlayer());
if (enemy.CurrentHP <= 0)
Output(new Output.Die());
Input(new Input.Alerted());
return ToSelf();
}
public Transition On(in Input.Killed input)
{
Output(new Output.Die());
return To<Idle>();
}
}
}
}