wave progress
This commit is contained in:
parent
f8f4de8d89
commit
8287cf609a
10 changed files with 107 additions and 3 deletions
26
scripts/gui/WaveProgress.cs
Normal file
26
scripts/gui/WaveProgress.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using Godot;
|
||||
|
||||
public partial class WaveProgress : TextureProgressBar
|
||||
{
|
||||
private TextureRect head;
|
||||
private Tween tween;
|
||||
|
||||
[Export] private double progressTime = 2.0f;
|
||||
public override void _Ready()
|
||||
{
|
||||
head = GetNode<TextureRect>("Head");
|
||||
}
|
||||
public void OnWaveChanged(int to)
|
||||
{
|
||||
if (Visible == false) Visible = true;
|
||||
if (tween != null) tween.Kill();
|
||||
tween = CreateTween().SetParallel(true).SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
|
||||
tween.TweenProperty(this,"value",to+1,progressTime);
|
||||
tween.TweenProperty(head,"anchor_right",1.0-(float)(to+1.0f)/MaxValue,progressTime);
|
||||
tween.TweenProperty(head,"anchor_left",1.0-(float)(to+1.0f)/MaxValue,progressTime);
|
||||
}
|
||||
public void SetLevelData(AdventureLevelResource resource)
|
||||
{
|
||||
MaxValue = resource.waves.Count;
|
||||
}
|
||||
}
|
||||
1
scripts/gui/WaveProgress.cs.uid
Normal file
1
scripts/gui/WaveProgress.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bsnt4slsbathn
|
||||
|
|
@ -9,6 +9,8 @@ public partial class LevelRunner : Node
|
|||
[Export] private RowSpawner rowSpawner;
|
||||
[Export] private Timer waveTimer;
|
||||
private int waveIndex = -1;
|
||||
[Signal] public delegate void ResourceChangedEventHandler(AdventureLevelResource resource);
|
||||
[Signal] public delegate void WaveChangedEventHandler(int to);
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -21,12 +23,13 @@ public partial class LevelRunner : Node
|
|||
waveTimer.Stop();
|
||||
waveTimer.WaitTime = resource.initialWaveDelay;
|
||||
waveTimer.Start();
|
||||
|
||||
EmitSignal(SignalName.ResourceChanged, resource);
|
||||
}
|
||||
|
||||
private void SummonWave()
|
||||
{
|
||||
waveIndex += 1;
|
||||
EmitSignal(SignalName.WaveChanged, waveIndex);
|
||||
rowSpawner.Add(resource.waves[waveIndex].zombiesOrdered);
|
||||
|
||||
if (waveIndex == resource.waves.Count - 1) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue