mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 06:25:54 +00:00
Random rooms
This commit is contained in:
parent
75ee779c37
commit
59f98ebf0e
13 changed files with 121 additions and 29 deletions
|
|
@ -1,9 +1,31 @@
|
|||
using Cirno.Scripts.Resources.Roguelite;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue