84 lines
2.3 KiB
C#
84 lines
2.3 KiB
C#
using Chickensoft.AutoInject;
|
|
using Chickensoft.Introspection;
|
|
using Godot;
|
|
using System.Collections.Immutable;
|
|
using Zennysoft.Ma.Adapter;
|
|
|
|
namespace Zennysoft.Game.Ma;
|
|
|
|
[Meta(typeof(IAutoNode))]
|
|
public partial class BossRoomA : SpecialFloor, IBossRoom, IDungeonFloor
|
|
{
|
|
public override void _Notification(int what) => this.Notify(what);
|
|
|
|
[Dependency] public IGame Game => this.DependOn<IGame>();
|
|
|
|
[Node] public Marker3D PlayerSpawnPoint { get; set; } = default!;
|
|
|
|
[Node] public Node3D HorseHeadStatue { get; set; } = default!;
|
|
|
|
[Node] public Node3D OxFaceStatue { get; set; } = default!;
|
|
|
|
[Node] public BossTypeA OxFace { get; set; } = default!;
|
|
|
|
[Node] public BossTypeA HorseHead { get; set; } = default!;
|
|
|
|
[Node] public Area3D ActivateTrap { get; set; } = default!;
|
|
|
|
[Node] public Node3D BossDoor { get; set; } = default!;
|
|
|
|
[Node] private Area3D _exit { get; set; } = default!;
|
|
|
|
public void OnReady()
|
|
{
|
|
ActivateTrap.BodyEntered += ActivateTrap_BodyEntered;
|
|
_exit.AreaEntered += Exit_AreaEntered;
|
|
OxFace.HealthComponent.HealthReachedZero += CheckForBossFightEnd;
|
|
HorseHead.HealthComponent.HealthReachedZero += CheckForBossFightEnd;
|
|
}
|
|
|
|
private void ActivateTrap_BodyEntered(Node3D body)
|
|
{
|
|
ActivateTrap.BodyEntered -= ActivateTrap_BodyEntered;
|
|
StartBossFight();
|
|
}
|
|
|
|
public void StartBossFight()
|
|
{
|
|
OxFaceStatue.Hide();
|
|
HorseHeadStatue.Hide();
|
|
OxFace.StartFight();
|
|
HorseHead.StartFight();
|
|
}
|
|
|
|
private void CheckForBossFightEnd()
|
|
{
|
|
if (OxFace.HealthComponent.CurrentHP.Value <= 0 && HorseHead.HealthComponent.CurrentHP.Value <= 0)
|
|
OnBossFightEnded();
|
|
}
|
|
|
|
public void OnBossFightEnded()
|
|
{
|
|
BossDoor.CallDeferred(MethodName.QueueFree);
|
|
}
|
|
|
|
public void ExitReached()
|
|
=> Game.FloorExitReached();
|
|
|
|
private void Exit_AreaEntered(Area3D area)
|
|
{
|
|
if (area.GetOwner() is IPlayer)
|
|
ExitReached();
|
|
}
|
|
|
|
public override (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPoint() { return (PlayerSpawnPoint.Rotation, new Vector3(PlayerSpawnPoint.GlobalPosition.X, -2.5f, PlayerSpawnPoint.GlobalPosition.Z)); }
|
|
|
|
public void OnExitTree()
|
|
{
|
|
ActivateTrap.BodyEntered -= ActivateTrap_BodyEntered;
|
|
_exit.AreaEntered -= Exit_AreaEntered;
|
|
OxFace.HealthComponent.HealthReachedZero -= CheckForBossFightEnd;
|
|
HorseHead.HealthComponent.HealthReachedZero -= CheckForBossFightEnd;
|
|
}
|
|
}
|