fully reset boss on player death

pull/6/head
John Montagu, the 4th Earl of Sandvich 2023-08-17 01:37:19 -07:00
parent 44e9be4124
commit bc6332e847
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
4 changed files with 20 additions and 4 deletions

View File

@ -38,6 +38,9 @@ public abstract partial class Boss : Enemy
}
}
[Export]
public float MaxHealth { get; set; }
public override void _Ready()
{
base._Ready();
@ -49,7 +52,7 @@ public abstract partial class Boss : Enemy
this.GetWorld().CurrentPlayer.Death += (args) =>
{
Reset();
IsActive = false;
};
_eventBus = this.GetEventBus();
@ -63,8 +66,6 @@ public abstract partial class Boss : Enemy
protected virtual void Reset()
{
IsActive = false;
// reset animations
foreach (var child in GetNode("Animations").GetChildren())
{
@ -79,5 +80,6 @@ public abstract partial class Boss : Enemy
StateMachine.ChangeState(StateMachine.InitialState);
ThinkerStateMachine.ChangeState(ThinkerStateMachine.InitialState);
Health = MaxHealth;
}
}

View File

@ -39,6 +39,10 @@ public partial class Doc : Boss
var coll = trig.GetNode<CollisionShape2D>("CollisionShape2D");
coll.Disabled = true;
}
else
{
Reset();
}
}
}
@ -131,4 +135,13 @@ public partial class Doc : Boss
}
base._Process(delta);
}
protected override void Reset()
{
base.Reset();
GlobalPosition = Vector2.Zero;
var trig = GetNode<InteractionTrigger>("InteractionTrigger");
var coll = trig.GetNode<CollisionShape2D>("CollisionShape2D");
coll.Disabled = false;
}
}

View File

@ -565,6 +565,7 @@ Lance = NodePath("Inventory/DocLance")
BossStateMachine = NodePath("BossStateMachine")
BossName = "Doc, The Two-Time"
Music = ExtResource("3_eo4lg")
MaxHealth = 900.0
DefaultSelectedItem = NodePath("Inventory/DocLance")
ThinkerStateMachine = NodePath("ThinkerStateMachine")
HandTexture = ExtResource("4_8lqj6")

View File

@ -66,7 +66,7 @@ public partial class BossBar : VBoxContainer
newBoss.Hurt += OnBossHurt;
newBoss.Death += OnBossDeath;
ProgressBar.MaxValue = newBoss.Health;
ProgressBar.MaxValue = newBoss.MaxHealth;
ProgressBar.Value = newBoss.Health;
Visible = true;