Hit/Death animations for bosses
This commit is contained in:
@@ -10,6 +10,8 @@ namespace GameJamDungeon
|
||||
{
|
||||
public AnimationTree AnimationTree { get; }
|
||||
|
||||
public AnimationPlayer HitAnimation { get; }
|
||||
|
||||
public Timer AttackTimer { get; }
|
||||
|
||||
public void Activate();
|
||||
@@ -56,13 +58,9 @@ namespace GameJamDungeon
|
||||
{
|
||||
BossBinding = BossLogic.Bind();
|
||||
BossBinding
|
||||
.Handle((in BossLogic.Output.HitByPlayer output) =>
|
||||
{
|
||||
|
||||
})
|
||||
.Handle((in BossLogic.Output.Defeated output) =>
|
||||
{
|
||||
QueueFree();
|
||||
HitAnimation.Play("Defeated");
|
||||
});
|
||||
this.Provide();
|
||||
BossLogic.Start();
|
||||
@@ -70,13 +68,19 @@ namespace GameJamDungeon
|
||||
CurrentHP.Sync += OnHPChanged;
|
||||
AttackTimer.Timeout += AttackTimer_Timeout;
|
||||
Hitbox.AreaEntered += Hitbox_AreaEntered;
|
||||
HitAnimation.AnimationFinished += HitAnimation_AnimationFinished;
|
||||
}
|
||||
|
||||
private void HitAnimation_AnimationFinished(StringName animName)
|
||||
{
|
||||
if (animName == "Defeated")
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
private void Hitbox_AreaEntered(Area3D area)
|
||||
{
|
||||
if (area is IHitbox)
|
||||
{
|
||||
HitAnimation.Play("Hit");
|
||||
var isCriticalHit = false;
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace GameJamDungeon
|
||||
public Transition On(in Input.HitByPlayer input)
|
||||
{
|
||||
var enemy = Get<IBoss>();
|
||||
enemy.HitAnimation.Play("Hit");
|
||||
enemy.CurrentHP.OnNext(enemy.CurrentHP.Value - input.Damage);
|
||||
GD.Print("Current HP: " + enemy.CurrentHP.Value);
|
||||
Output(new Output.HitByPlayer());
|
||||
|
||||
Reference in New Issue
Block a user