Intro with new animator

This commit is contained in:
Marco 2025-02-25 14:06:41 +01:00
commit cd43b3361d
16 changed files with 788 additions and 19 deletions

View file

@ -9,6 +9,8 @@ namespace Cirno.Scripts.UI;
public partial class IntroScenePlayer : CanvasLayer
{
[Export] public bool StartRunning { get; private set; }
[Export]
public Control PanelsHolder { get; private set; }
@ -21,6 +23,9 @@ public partial class IntroScenePlayer : CanvasLayer
[Export]
public string NextSceneName { get; set; }
[Export]
public AnimationPlayer AnimationPlayer { get; private set; }
private int _currentPanelIndex;
private List<TextureRect> _panels = new ();
@ -30,12 +35,20 @@ public partial class IntroScenePlayer : CanvasLayer
private double _timer = 0f;
private bool _running = false;
private void DeferredStartAnimation()
{
AnimationPlayer.Play("intro");
}
public override void _Ready()
{
_timer = 0;
_running = true;
_running = StartRunning;
DeferredStartAnimation();
return;
foreach (var image in Images)
{
var panel = new TextureRect();
@ -49,11 +62,19 @@ public partial class IntroScenePlayer : CanvasLayer
_panels.Add(panel);
}
if (StartRunning)
{
Run();
}
}
public void Run()
{
var first = _panels.First();
first.Visible = true;
first.SetModulate(new Color(first.Modulate.R, first.Modulate.G, first.Modulate.B, 1f));
}
public override void _Process(double delta)
@ -70,21 +91,26 @@ public partial class IntroScenePlayer : CanvasLayer
if (_timer >= TransitionTime)
{
_timer = 0;
_currentPanelIndex++;
if (_currentPanelIndex >= _panels.Count)
{
_running = false;
Finished();
return;
}
_running = false;
_ = Transition();
NextPanel();
}
}
public void NextPanel()
{
_currentPanelIndex++;
if (_currentPanelIndex >= _panels.Count)
{
_running = false;
Finished();
return;
}
_running = false;
_ = Transition();
}
private void Finished()
{
GlobalState.Instance.GotoScene(NextSceneName);