mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
65 lines
No EOL
1.4 KiB
C#
65 lines
No EOL
1.4 KiB
C#
using Cirno.Scripts.Resources;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.Actors;
|
|
|
|
public partial class Boss : Enemy, IActivable
|
|
{
|
|
[Export] private Array<BossPhase> Phases;
|
|
private int currentPhaseIndex = 0;
|
|
|
|
private bool _started = false;
|
|
|
|
private GameManager _gameManager;
|
|
|
|
private Vector2 _homePosition;
|
|
public Vector2 HomePosition => _homePosition;
|
|
|
|
public GameManager GameManager => _gameManager;
|
|
|
|
private BossPhase CurrentPhase => Phases[currentPhaseIndex];
|
|
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
_gameManager = GetNode<GameManager>("/root/GameScene");
|
|
|
|
_homePosition = this.GlobalPosition;
|
|
|
|
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
base._Process(delta);
|
|
|
|
if (!_started) return;
|
|
|
|
CurrentPhase.UpdatePhase(delta);
|
|
if (_currentHealth <= CurrentPhase.Threshold && currentPhaseIndex + 1 < Phases.Count)
|
|
{
|
|
currentPhaseIndex++;
|
|
StartPhase(CurrentPhase);
|
|
}
|
|
|
|
}
|
|
|
|
private void StartPhase(BossPhase phase)
|
|
{
|
|
phase.Start(this);
|
|
}
|
|
|
|
public void TakeDamage(int amount)
|
|
{
|
|
if (!_started) return;
|
|
|
|
_currentHealth -= amount;
|
|
}
|
|
|
|
public void Activate()
|
|
{
|
|
_started = true;
|
|
StartPhase(CurrentPhase);
|
|
}
|
|
} |