complete refactor
This commit is contained in:
parent
65fe0e5c5d
commit
de2e8b1e50
71 changed files with 212 additions and 137 deletions
|
|
@ -1,60 +0,0 @@
|
|||
using Godot;
|
||||
using Newlon.Components.GUI;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
|
||||
namespace Newlon;
|
||||
|
||||
public partial class Sun : Area2D
|
||||
{
|
||||
[Export] public int amount = 25;
|
||||
[Export] private Timer _deathTimer;
|
||||
[Export] private AnimationPlayer _rotation;
|
||||
[Export] private AnimationPlayer _fade;
|
||||
|
||||
private bool scoring;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_rotation.SpeedScale = 1.0f + GD.Randf() / 2.0f;
|
||||
}
|
||||
public override void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx)
|
||||
{
|
||||
if (Settings.SunClick == false || scoring) return;
|
||||
|
||||
if (@event.IsActionPressed("primary_action"))
|
||||
{
|
||||
ScoreSun();
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (scoring) return;
|
||||
if (_deathTimer.TimeLeft / _deathTimer.WaitTime <= 0.25)
|
||||
{
|
||||
_fade.Play("main");
|
||||
}
|
||||
}
|
||||
public override void _MouseEnter()
|
||||
{
|
||||
if (Settings.SunClick || scoring) return;
|
||||
ScoreSun();
|
||||
}
|
||||
private void ScoreSun()
|
||||
{
|
||||
_fade.Stop();
|
||||
scoring = true;
|
||||
|
||||
RuntimeLevelData.Instance.AddSun(amount,false);
|
||||
|
||||
GetNode<ChannelPlayer>("SunPlayer").Play();
|
||||
var tween = CreateTween();
|
||||
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(() =>
|
||||
{
|
||||
SunCounter.Update();
|
||||
QueueFree();
|
||||
}));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue