mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-06 09:15:55 +00:00
Boss phase animations
This commit is contained in:
parent
1db132d77d
commit
b4fdb9c9e3
8 changed files with 90 additions and 9 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using Cirno.Scripts.Resources;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.UI;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
|
|
@ -12,13 +14,18 @@ public partial class Boss : Enemy, IActivable
|
|||
private bool _started = false;
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
public GameManager GameManager => _gameManager;
|
||||
private Vector2 _homePosition;
|
||||
public Vector2 HomePosition => _homePosition;
|
||||
|
||||
public GameManager GameManager => _gameManager;
|
||||
|
||||
private BossPhase CurrentPhase => Phases[currentPhaseIndex];
|
||||
|
||||
// [Export]
|
||||
// private PackedScene _bossPhaseAnimationPrefab;
|
||||
|
||||
private TextureRect _animationTextureRect;
|
||||
|
||||
[Export]
|
||||
private Texture2D _bossPortraitTexture;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -26,6 +33,29 @@ public partial class Boss : Enemy, IActivable
|
|||
_gameManager = this.GetGameManager();
|
||||
|
||||
_homePosition = this.GlobalPosition;
|
||||
|
||||
if (_bossPortraitTexture is not null)
|
||||
{
|
||||
var canvas = new CanvasLayer();
|
||||
canvas.Name = "BossPhaseAnimationCanvas";
|
||||
|
||||
_gameManager.CallDeferred("add_child", canvas);
|
||||
|
||||
_animationTextureRect = new TextureRect();
|
||||
_animationTextureRect.Texture = _bossPortraitTexture;
|
||||
|
||||
canvas.CallDeferred("add_child", _animationTextureRect);
|
||||
|
||||
//canvas.AddChild(animationTextureRect);
|
||||
|
||||
_animationTextureRect.Position = new Vector2(180, 10);
|
||||
|
||||
_animationTextureRect.Visible = false;
|
||||
|
||||
//var animation = _bossPhaseAnimationPrefab.Instantiate<BossPhaseAnimation>();
|
||||
|
||||
// _gameManager.AddChild(animation);
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
|
|
@ -45,7 +75,14 @@ public partial class Boss : Enemy, IActivable
|
|||
|
||||
private void StartPhase(BossPhase phase)
|
||||
{
|
||||
phase.Start(this);
|
||||
if (phase.PlayAnimation)
|
||||
{
|
||||
_ = Switchphase(phase);
|
||||
}
|
||||
else
|
||||
{
|
||||
phase.Start(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeDamage(int amount)
|
||||
|
|
@ -60,4 +97,34 @@ public partial class Boss : Enemy, IActivable
|
|||
_started = true;
|
||||
StartPhase(CurrentPhase);
|
||||
}
|
||||
|
||||
private async Task Switchphase(BossPhase phase)
|
||||
{
|
||||
await PlayAnimation();
|
||||
|
||||
phase.Start(this);
|
||||
}
|
||||
|
||||
private async Task PlayAnimation()
|
||||
{
|
||||
_animationTextureRect.Modulate = new Color(_animationTextureRect.Modulate.R, _animationTextureRect.Modulate.G, _animationTextureRect.Modulate.B, 0f);
|
||||
_animationTextureRect.Visible = true;
|
||||
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.SetEase(Tween.EaseType.InOut);
|
||||
tween.SetTrans(Tween.TransitionType.Linear);
|
||||
|
||||
tween.TweenProperty(_animationTextureRect, "modulate:a", 1f, 0.2f);
|
||||
|
||||
tween.TweenProperty(_animationTextureRect, "global_position", _animationTextureRect.GlobalPosition + new Vector2(-64f, 20f), 1.5f);
|
||||
|
||||
tween.TweenProperty(_animationTextureRect, "modulate:a", 0f, 0.2f);
|
||||
|
||||
//await Task.Delay(800);
|
||||
|
||||
// Wait for the tween to finish
|
||||
await ToSignal(tween, "finished");
|
||||
|
||||
_animationTextureRect.Visible = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ public partial class Hud : CanvasLayer
|
|||
[Export] private LabelSettings _labelSettings;
|
||||
|
||||
private Dictionary<string, HudItem> _items = new();
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
// Assuming the HUD has a Label node named "HealthLabel"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace Cirno.Scripts.Resources;
|
|||
public partial class BossPhase : Resource
|
||||
{
|
||||
[Export] public int Threshold;
|
||||
[Export] public bool PlayAnimation;
|
||||
[Export] public Array<AttackPattern> Patterns;
|
||||
|
||||
private int currentPatternIndex = 0;
|
||||
|
|
|
|||
8
Scripts/UI/BossPhaseAnimation.cs
Normal file
8
Scripts/UI/BossPhaseAnimation.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.UI;
|
||||
|
||||
public partial class BossPhaseAnimation : TextureRect
|
||||
{
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue