Repository navigation
Expand file tree
/
Copy pathSetup.cs
More file actions
72 lines (57 loc) · 1.89 KB
/
Copy pathSetup.cs
File metadata and controls
72 lines (57 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Diagnostics;
using Godot;
using LD60.Helpers;
namespace LD60;
public partial class Setup : Control
{
[Export(PropertyHint.File, "*.tscn")]
public string NextScenePath { get; set; } = "res://scenes/tutorial.tscn";
[Export]
public Button? ProceedButton { get; set; }
[Export]
public Label? ByLineLabel { get; set; }
private MorseManager? _morseManager;
private int _delay = 2;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
ByLineLabel?.Text += ProjectSettings.Singleton.Get("application/config/version");
var audioManager = GetNode<AudioManager>("/root/AudioManager");
_morseManager = new(audioManager);
_morseManager.QueueCompleted += MorseManagerOnQueueCompleted;
// Kick us off
MorseManagerOnQueueCompleted(this, EventArgs.Empty);
Shell.Instance?.PreloadScene(NextScenePath);
}
private void MorseManagerOnQueueCompleted(object? sender, EventArgs e)
{
if (_delay > 0)
{
_delay--;
if (_delay == 0)
{
// Show proceed button after first SOS
Tween tween = CreateTween();
tween.TweenProperty(ProceedButton, "modulate:a", 1.0, 2.0);
tween.Play();
}
}
// Put a small gap before we start again
_morseManager?.Queue(" SOS", true);
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
_morseManager?.Process(delta);
}
public void OnProceedButtonPressed()
{
ProceedButton?.Disabled = true;
Shell.Instance?.TransitionTo(NextScenePath);
}
public void OnCreditsButtonPressed()
{
Shell.Instance?.TransitionTo("res://scenes/credits.tscn");
}
}