fully reset boss on player death
parent
44e9be4124
commit
bc6332e847
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue