32 lines
922 B
C#
32 lines
922 B
C#
using System.Globalization;
|
|
using Godot;
|
|
using Newlon.Components.Level;
|
|
|
|
namespace Newlon.Components.GUI;
|
|
|
|
public partial class SunCounter : Control
|
|
{
|
|
public static SunCounter Instance { get; private set; }
|
|
private Tween tween;
|
|
[Export] private Label text;
|
|
[Export] public TextureRect sunImage { get; private set;}
|
|
public override void _EnterTree()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
public static void Update()
|
|
{
|
|
if (Instance.tween != null) Instance.tween.Kill();
|
|
Instance.tween = Instance.CreateTween();
|
|
Instance.tween.TweenMethod(Callable.From<int>(Instance.SetText), int.Parse(Instance.text.Text), RuntimeLevelData.Instance.SunCount, 1.0);
|
|
}
|
|
public static void UpdateInstantly()
|
|
{
|
|
Instance.text.Text = RuntimeLevelData.Instance.SunCount.ToString();
|
|
}
|
|
private void SetText(int value)
|
|
{
|
|
text.Text = value.ToString();
|
|
}
|
|
}
|