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,4 +1,5 @@
using Godot;
using Newlon.Components.GUI;
using Newlon.Components.Level;
@ -6,8 +7,6 @@ namespace Newlon;
public partial class Sun : Area2D
{
public static Control Counter;
[Export] public int amount = 25;
[Export] private Timer _deathTimer;
[Export] private AnimationPlayer _rotation;
@ -39,21 +38,22 @@ public partial class Sun : Area2D
}
public override void _MouseEnter()
{
if (Settings.SunClick) return;
if (Settings.SunClick || scoring) return;
ScoreSun();
}
private void ScoreSun()
{
_fade.Stop();
scoring = true;
RuntimeLevelData.Instance.AddSun(amount);
GetNode<ChannelPlayer>("SunPlayer").Play();
var tween = CreateTween();
tween.TweenInterval(0.1);
tween.TweenProperty(this, "global_position", GetCanvasTransform().AffineInverse() * (Counter.GlobalPosition + Counter.PivotOffset), 0.5).SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
tween.TweenProperty(this, "global_position", GetCanvasTransform().AffineInverse() * (SunCounter.Instance.sunImage.GlobalPosition + SunCounter.Instance.sunImage.PivotOffset), 0.5).SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
tween.TweenCallback(Callable.From(() =>
{
RuntimeLevelData.Instance.AddSun(amount);
SunCounter.Update();
QueueFree();
}));
}