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()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
base._Ready();
|
base._Ready();
|
||||||
|
@ -49,7 +52,7 @@ public abstract partial class Boss : Enemy
|
||||||
|
|
||||||
this.GetWorld().CurrentPlayer.Death += (args) =>
|
this.GetWorld().CurrentPlayer.Death += (args) =>
|
||||||
{
|
{
|
||||||
Reset();
|
IsActive = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
_eventBus = this.GetEventBus();
|
_eventBus = this.GetEventBus();
|
||||||
|
@ -63,8 +66,6 @@ public abstract partial class Boss : Enemy
|
||||||
|
|
||||||
protected virtual void Reset()
|
protected virtual void Reset()
|
||||||
{
|
{
|
||||||
IsActive = false;
|
|
||||||
|
|
||||||
// reset animations
|
// reset animations
|
||||||
foreach (var child in GetNode("Animations").GetChildren())
|
foreach (var child in GetNode("Animations").GetChildren())
|
||||||
{
|
{
|
||||||
|
@ -79,5 +80,6 @@ public abstract partial class Boss : Enemy
|
||||||
|
|
||||||
StateMachine.ChangeState(StateMachine.InitialState);
|
StateMachine.ChangeState(StateMachine.InitialState);
|
||||||
ThinkerStateMachine.ChangeState(ThinkerStateMachine.InitialState);
|
ThinkerStateMachine.ChangeState(ThinkerStateMachine.InitialState);
|
||||||
|
Health = MaxHealth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,10 @@ public partial class Doc : Boss
|
||||||
var coll = trig.GetNode<CollisionShape2D>("CollisionShape2D");
|
var coll = trig.GetNode<CollisionShape2D>("CollisionShape2D");
|
||||||
coll.Disabled = true;
|
coll.Disabled = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,4 +135,13 @@ public partial class Doc : Boss
|
||||||
}
|
}
|
||||||
base._Process(delta);
|
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")
|
BossStateMachine = NodePath("BossStateMachine")
|
||||||
BossName = "Doc, The Two-Time"
|
BossName = "Doc, The Two-Time"
|
||||||
Music = ExtResource("3_eo4lg")
|
Music = ExtResource("3_eo4lg")
|
||||||
|
MaxHealth = 900.0
|
||||||
DefaultSelectedItem = NodePath("Inventory/DocLance")
|
DefaultSelectedItem = NodePath("Inventory/DocLance")
|
||||||
ThinkerStateMachine = NodePath("ThinkerStateMachine")
|
ThinkerStateMachine = NodePath("ThinkerStateMachine")
|
||||||
HandTexture = ExtResource("4_8lqj6")
|
HandTexture = ExtResource("4_8lqj6")
|
||||||
|
|
|
@ -66,7 +66,7 @@ public partial class BossBar : VBoxContainer
|
||||||
newBoss.Hurt += OnBossHurt;
|
newBoss.Hurt += OnBossHurt;
|
||||||
newBoss.Death += OnBossDeath;
|
newBoss.Death += OnBossDeath;
|
||||||
|
|
||||||
ProgressBar.MaxValue = newBoss.Health;
|
ProgressBar.MaxValue = newBoss.MaxHealth;
|
||||||
ProgressBar.Value = newBoss.Health;
|
ProgressBar.Value = newBoss.Health;
|
||||||
|
|
||||||
Visible = true;
|
Visible = true;
|
||||||
|
|
Loading…
Reference in New Issue