mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
31 lines
No EOL
847 B
C#
31 lines
No EOL
847 B
C#
using System.Linq;
|
|
using Cirno.Scripts.Resources;
|
|
using Cirno.Scripts.Resources.Roguelite;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.Controllers;
|
|
|
|
public partial class RogueliteRoom : Node2D
|
|
{
|
|
[Export] public RogueliteRoomResource RoomResource { get; set; }
|
|
|
|
private Array<EnemyResource> SpawnableEnemies => RoomResource.SpawnableEnemies;
|
|
|
|
public void Spawn()
|
|
{
|
|
var enemySpawners = this.GetNode("EnemySpawners").GetChildren().Cast<Marker2D>();
|
|
|
|
foreach (var spawner in enemySpawners)
|
|
{
|
|
|
|
var index = GD.RandRange(0, SpawnableEnemies.Count - 1);
|
|
|
|
var e = SpawnableEnemies[index];
|
|
|
|
var enemyScene = GD.Load<PackedScene>(e.PrefabPath);
|
|
var spawnedEnemy = spawner.CreateChild<Node2D>(enemyScene);
|
|
}
|
|
|
|
}
|
|
} |