counter +1

This commit is contained in:
Rendo 2025-07-19 19:29:45 +05:00
commit 92ebb2868d
11 changed files with 50 additions and 39 deletions

View file

@ -1,12 +1,32 @@
using System.Globalization;
using Godot;
using Newlon.Components.Level;
namespace Newlon.Components.GUI;
public partial class SunCounter : Label
public partial class SunCounter : Control
{
public override void _Process(double delta)
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()
{
Text = RuntimeLevelData.Instance.SunCount.ToString();
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();
}
}