34 lines
806 B
C#
34 lines
806 B
C#
using Godot;
|
|
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;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_rotation.SpeedScale = 1.0f + GD.Randf() / 2.0f;
|
|
}
|
|
public override void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx)
|
|
{
|
|
if (@event.IsActionPressed("primary_action"))
|
|
{
|
|
RuntimeLevelData.Instance.AddSun(amount);
|
|
QueueFree();
|
|
}
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (_deathTimer.TimeLeft/_deathTimer.WaitTime <= 0.25)
|
|
{
|
|
_fade.Play("main");
|
|
}
|
|
}
|
|
}
|