mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-22 19:43:55 +00:00
Cleaned up intro scene player
This commit is contained in:
parent
0c0174e0ab
commit
12b8d4a70f
1 changed files with 7 additions and 72 deletions
|
|
@ -32,10 +32,10 @@ public partial class IntroScenePlayer : CanvasLayer
|
||||||
|
|
||||||
public TextureRect CurrentPanel => _panels[_currentPanelIndex];
|
public TextureRect CurrentPanel => _panels[_currentPanelIndex];
|
||||||
|
|
||||||
private double _timer = 0f;
|
|
||||||
|
|
||||||
private bool _running = false;
|
private bool _running = false;
|
||||||
|
|
||||||
|
private bool _isEnding = false;
|
||||||
|
|
||||||
private void DeferredStartAnimation()
|
private void DeferredStartAnimation()
|
||||||
{
|
{
|
||||||
AnimationPlayer.Play("intro");
|
AnimationPlayer.Play("intro");
|
||||||
|
|
@ -43,31 +43,9 @@ public partial class IntroScenePlayer : CanvasLayer
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_timer = 0;
|
|
||||||
_running = StartRunning;
|
_running = StartRunning;
|
||||||
|
|
||||||
DeferredStartAnimation();
|
DeferredStartAnimation();
|
||||||
|
|
||||||
return;
|
|
||||||
foreach (var image in Images)
|
|
||||||
{
|
|
||||||
var panel = new TextureRect();
|
|
||||||
panel.Texture = image;
|
|
||||||
panel.ExpandMode = TextureRect.ExpandModeEnum.KeepSize;
|
|
||||||
panel.StretchMode = TextureRect.StretchModeEnum.KeepAspectCentered;
|
|
||||||
panel.Visible = false;
|
|
||||||
panel.SetModulate(new Color(panel.Modulate.R, panel.Modulate.G, panel.Modulate.B, 0f));
|
|
||||||
|
|
||||||
PanelsHolder.CallDeferred("add_child", panel);
|
|
||||||
|
|
||||||
_panels.Add(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StartRunning)
|
|
||||||
{
|
|
||||||
Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
|
@ -79,61 +57,18 @@ public partial class IntroScenePlayer : CanvasLayer
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (Input.IsAnythingPressed())
|
if (!_isEnding && Input.IsAnythingPressed())
|
||||||
{
|
{
|
||||||
Finished();
|
Finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_running) return;
|
|
||||||
|
|
||||||
_timer += delta;
|
|
||||||
|
|
||||||
if (_timer >= TransitionTime)
|
|
||||||
{
|
|
||||||
_timer = 0;
|
|
||||||
NextPanel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void NextPanel()
|
|
||||||
{
|
|
||||||
_currentPanelIndex++;
|
|
||||||
|
|
||||||
if (_currentPanelIndex >= _panels.Count)
|
|
||||||
{
|
|
||||||
_running = false;
|
|
||||||
Finished();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_running = false;
|
|
||||||
|
|
||||||
_ = Transition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Finished()
|
private void Finished()
|
||||||
{
|
{
|
||||||
|
if (_isEnding) return;
|
||||||
|
|
||||||
|
_isEnding = true;
|
||||||
GlobalState.Instance.GotoScene(NextSceneName);
|
GlobalState.Instance.GotoScene(NextSceneName);
|
||||||
//GetTree().ChangeSceneToFile(NextSceneName);
|
//GetTree().ChangeSceneToFile(NextSceneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Transition()
|
|
||||||
{
|
|
||||||
TextureRect previousPanel = _panels[_currentPanelIndex-1];
|
|
||||||
|
|
||||||
CurrentPanel.Visible = true;
|
|
||||||
|
|
||||||
var tween = GetTree().CreateTween();
|
|
||||||
tween.SetEase(Tween.EaseType.InOut);
|
|
||||||
tween.SetTrans(Tween.TransitionType.Linear);
|
|
||||||
tween.TweenProperty(previousPanel, "modulate:a", 0f, 1f);
|
|
||||||
|
|
||||||
tween.TweenProperty(CurrentPanel, "modulate:a", 1f, 1f);
|
|
||||||
|
|
||||||
await ToSignal(tween, "finished");
|
|
||||||
|
|
||||||
previousPanel.Visible = false;
|
|
||||||
|
|
||||||
_running = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue