newlon/scripts/level/SunSpawner.cs
2025-07-17 11:44:10 +05:00

29 lines
793 B
C#

using Godot;
namespace Newlon.Components.Level;
public partial class SunSpawner : Node
{
[Export]
public int MinSun = 25;
[Export]
public int MaxSun = 25;
[Export]
private PackedScene SunScene;
public void Spawn()
{
float x = GD.Randf()*9*FieldParams.TileWidth;
uint y = GD.Randi() % 5;
var sun = SunScene.Instantiate<Sun>();
PoolContainer.Instance.Projectiles.AddChild(sun);
sun.GlobalPosition = new Vector2(FieldParams.LeftFieldBoundary.X + x, -90);
var moveTween = CreateTween();
moveTween.TweenProperty(sun,"global_position", new Vector2(FieldParams.LeftFieldBoundary.X + x,
FieldParams.LeftFieldBoundary.Y + FieldParams.TileHeight * y + FieldParams.TileHeight/2.0f),9-y);
}
}