26 lines
797 B
C#
26 lines
797 B
C#
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;
|
|
}
|
|
}
|