mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 09:05:53 +00:00
Boss HUD
This commit is contained in:
parent
b4fdb9c9e3
commit
4be64cf7ec
12 changed files with 220 additions and 33 deletions
|
|
@ -8,7 +8,9 @@ namespace Cirno.Scripts.Actors;
|
|||
|
||||
public partial class Boss : Enemy, IActivable
|
||||
{
|
||||
[Export] public string BossName { get; private set; }
|
||||
[Export] private Array<BossPhase> Phases;
|
||||
[Export] private PackedScene BossHudPrefab;
|
||||
private int currentPhaseIndex = 0;
|
||||
|
||||
private bool _started = false;
|
||||
|
|
@ -26,6 +28,8 @@ public partial class Boss : Enemy, IActivable
|
|||
|
||||
[Export]
|
||||
private Texture2D _bossPortraitTexture;
|
||||
|
||||
private BossHud _bossHud;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -34,28 +38,45 @@ public partial class Boss : Enemy, IActivable
|
|||
|
||||
_homePosition = this.GlobalPosition;
|
||||
|
||||
if (_bossPortraitTexture is not null)
|
||||
if (BossHudPrefab is not null)
|
||||
{
|
||||
var canvas = new CanvasLayer();
|
||||
canvas.Name = "BossPhaseAnimationCanvas";
|
||||
_bossHud = BossHudPrefab.Instantiate<BossHud>();
|
||||
_gameManager.CallDeferred("add_child", _bossHud);
|
||||
|
||||
_bossHud.BossName = BossName;
|
||||
_bossHud.BossMaxHealth = this.Health;
|
||||
_bossHud.BossHealth = this._currentHealth;
|
||||
_bossHud.SpellCardName = CurrentPhase.PhaseName;
|
||||
|
||||
// TODO: Do some translation for health values to match the thresholds
|
||||
this.HealthChanged += (float newValue) => {_bossHud.BossHealth = newValue;};
|
||||
|
||||
if (_bossPortraitTexture is not null)
|
||||
{
|
||||
// var canvas = new CanvasLayer();
|
||||
// canvas.Name = "BossPhaseAnimationCanvas";
|
||||
|
||||
_gameManager.CallDeferred("add_child", canvas);
|
||||
// _gameManager.CallDeferred("add_child", canvas);
|
||||
|
||||
_animationTextureRect = new TextureRect();
|
||||
_animationTextureRect.Texture = _bossPortraitTexture;
|
||||
_animationTextureRect = new TextureRect();
|
||||
_animationTextureRect.Texture = _bossPortraitTexture;
|
||||
|
||||
canvas.CallDeferred("add_child", _animationTextureRect);
|
||||
_bossHud.CallDeferred("add_child", _animationTextureRect);
|
||||
|
||||
//canvas.AddChild(animationTextureRect);
|
||||
//canvas.AddChild(animationTextureRect);
|
||||
|
||||
_animationTextureRect.Position = new Vector2(180, 10);
|
||||
_animationTextureRect.Position = new Vector2(180, 10);
|
||||
|
||||
_animationTextureRect.Visible = false;
|
||||
_animationTextureRect.Visible = false;
|
||||
|
||||
//var animation = _bossPhaseAnimationPrefab.Instantiate<BossPhaseAnimation>();
|
||||
//var animation = _bossPhaseAnimationPrefab.Instantiate<BossPhaseAnimation>();
|
||||
|
||||
// _gameManager.AddChild(animation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
|
|
@ -68,6 +89,7 @@ public partial class Boss : Enemy, IActivable
|
|||
if (_currentHealth <= CurrentPhase.Threshold && currentPhaseIndex + 1 < Phases.Count)
|
||||
{
|
||||
currentPhaseIndex++;
|
||||
_bossHud.SpellCardName = CurrentPhase.PhaseName;
|
||||
StartPhase(CurrentPhase);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue