Revamp boss logic
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
@@ -9,28 +9,37 @@ public partial class BossRoomA : Node3D, IBossRoom
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||
|
||||
[Node] public Marker3D PlayerSpawn { get; set; } = default!;
|
||||
|
||||
[Node] public Node3D HorseHeadStatue { get; set; } = default!;
|
||||
|
||||
[Node] public Node3D OxFaceStatue { get; set; } = default!;
|
||||
|
||||
[Node] public Boss OxFace { get; set; } = default!;
|
||||
[Node] public BossTypeA OxFace { get; set; } = default!;
|
||||
|
||||
[Node] public Boss HorseFace { get; set; } = default!;
|
||||
[Node] public BossTypeA HorseFace { get; set; } = default!;
|
||||
|
||||
[Node] public Area3D ActivateTrap { get; set; } = default!;
|
||||
|
||||
[Node] public Node3D GateCollision { get; set; } = default!;
|
||||
|
||||
[Node] private Area3D _exit { get; set; } = default!;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
ActivateTrap.BodyEntered += ActivateTrap_BodyEntered;
|
||||
OxFace.IsDefeated.Sync += BossStatusUpdate;
|
||||
HorseFace.IsDefeated.Sync += BossStatusUpdate;
|
||||
OxFace.CurrentHP.Sync += BossStatusUpdate;
|
||||
HorseFace.CurrentHP.Sync += BossStatusUpdate;
|
||||
_exit.AreaEntered += Exit_AreaEntered;
|
||||
}
|
||||
|
||||
private void ActivateTrap_BodyEntered(Node3D body) => StartBossFight();
|
||||
private void ActivateTrap_BodyEntered(Node3D body)
|
||||
{
|
||||
ActivateTrap.BodyEntered -= ActivateTrap_BodyEntered;
|
||||
StartBossFight();
|
||||
}
|
||||
|
||||
public void StartBossFight()
|
||||
{
|
||||
@@ -45,9 +54,14 @@ public partial class BossRoomA : Node3D, IBossRoom
|
||||
GateCollision.CallDeferred(MethodName.QueueFree);
|
||||
}
|
||||
|
||||
private void BossStatusUpdate(bool obj)
|
||||
private void BossStatusUpdate(double hp)
|
||||
{
|
||||
if (OxFace.IsDefeated.Value && HorseFace.IsDefeated.Value)
|
||||
if (OxFace.CurrentHP.Value <= 0 && HorseFace.CurrentHP.Value <= 0)
|
||||
OnBossFightEnded();
|
||||
}
|
||||
|
||||
public void ExitReached()
|
||||
=> Game.FloorExitReached();
|
||||
|
||||
private void Exit_AreaEntered(Area3D area) => ExitReached();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user