35 lines
878 B
C#
35 lines
878 B
C#
using Godot;
|
|
|
|
namespace AceFieldNewHorizon.Scripts.Tiles;
|
|
|
|
public partial class EnemyNestTile : BaseTile
|
|
{
|
|
[Export] public PackedScene EnemyScene;
|
|
private Timer _spawnTimer;
|
|
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
|
|
// Create and configure the timer
|
|
_spawnTimer = new Timer();
|
|
AddChild(_spawnTimer);
|
|
_spawnTimer.Timeout += OnSpawnTimerTimeout;
|
|
_spawnTimer.Start(1.0f); // Start with 1 second interval
|
|
}
|
|
|
|
private void OnSpawnTimerTimeout()
|
|
{
|
|
if (EnemyScene != null)
|
|
{
|
|
var enemy = EnemyScene.Instantiate();
|
|
GetParent().AddChild(enemy);
|
|
|
|
// Position the enemy at the nest's position
|
|
if (enemy is Node2D enemy2D)
|
|
{
|
|
enemy2D.GlobalPosition = GlobalPosition;
|
|
}
|
|
}
|
|
}
|
|
} |