mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 11:25:55 +00:00
Locked Doors
This commit is contained in:
parent
e62b539a1e
commit
e25da0fe16
20 changed files with 318 additions and 61 deletions
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Resources.Roguelite;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
|
@ -12,9 +13,9 @@ namespace Cirno.Scripts.Controllers;
|
|||
|
||||
public partial class RogueliteRoomManager : Node2D
|
||||
{
|
||||
[Export] public Array<RogueliteRoomResource> Rooms { get; set; }
|
||||
|
||||
[Export] public Node2D SceneContainer { get; set; }
|
||||
//[Export] public Array<RogueliteRoomResource> Rooms { get; set; }
|
||||
|
||||
[Export] public RogueliteMapTheme MapTheme { get; set; }
|
||||
|
||||
//private Godot.Collections.Dictionary<Vector2I, RogueliteRoomResource> _grid = new();
|
||||
private Godot.Collections.Dictionary<Vector2I, RogueliteRoom> _roomGrid = new();
|
||||
|
|
@ -69,8 +70,8 @@ public partial class RogueliteRoomManager : Node2D
|
|||
{
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
var roomIndex = GD.RandRange(0, Rooms.Count - 1);
|
||||
var room = Rooms[roomIndex];
|
||||
var roomIndex = GD.RandRange(0, MapTheme.Rooms.Count - 1);
|
||||
var room = MapTheme.Rooms[roomIndex];
|
||||
//SpawnRoom(room, origin + (room.Size * new Vector2(i, j) * tileSize));
|
||||
}
|
||||
}
|
||||
|
|
@ -78,15 +79,15 @@ public partial class RogueliteRoomManager : Node2D
|
|||
//CallDeferred(MethodName.RebakeNavigationDeferred);
|
||||
}
|
||||
|
||||
private IEnumerable<RogueliteRoomResource> StarterRooms => Rooms.Where(x => x.Type is RoomType.Starter);
|
||||
private IEnumerable<RogueliteRoomResource> StarterRooms => MapTheme.Rooms.Where(x => x.Type is RoomType.Starter);
|
||||
|
||||
private IEnumerable<RogueliteRoomResource> RegularRooms => Rooms.Where(x =>
|
||||
private IEnumerable<RogueliteRoomResource> RegularRooms => MapTheme.Rooms.Where(x =>
|
||||
x.Type is RoomType.Regular && x.HasDoors(DoorDirections.North | DoorDirections.South));
|
||||
|
||||
private IEnumerable<RogueliteRoomResource> OffshootRooms => Rooms.Where(x =>
|
||||
private IEnumerable<RogueliteRoomResource> OffshootRooms => MapTheme.Rooms.Where(x =>
|
||||
x.Type is RoomType.Regular && x.HasDoors(DoorDirections.East | DoorDirections.West));
|
||||
|
||||
private IEnumerable<RogueliteRoomResource> BossRooms => Rooms.Where(x => x.Type is RoomType.Boss);
|
||||
private IEnumerable<RogueliteRoomResource> BossRooms => MapTheme.Rooms.Where(x => x.Type is RoomType.Boss);
|
||||
|
||||
private List<RoomConnection> _connections = new();
|
||||
|
||||
|
|
@ -100,7 +101,7 @@ public partial class RogueliteRoomManager : Node2D
|
|||
}
|
||||
|
||||
Vector2I origin = Vector2I.Zero;
|
||||
var starterRoom = Rooms.Where(r => r.Type == RoomType.Starter).PickRandom();
|
||||
var starterRoom = MapTheme.Rooms.Where(r => r.Type == RoomType.Starter).PickRandom();
|
||||
SpawnRoom(starterRoom, origin, out var spawnedBeginRoom);
|
||||
|
||||
var randomRoomsList = RegularRooms.Shuffle(MaxRooms * 4).ToList();
|
||||
|
|
@ -372,7 +373,7 @@ public partial class RogueliteRoomManager : Node2D
|
|||
// Spawn final room
|
||||
// var finalRoomToSpawn = Rooms.Where(x => x.Type == offshootTypeToSpawn).PickRandom();
|
||||
|
||||
var spawnedFinalRoom = TrySpawnRoom(Rooms.Where(x => x.Type == offshootTypeToSpawn).ToList(),
|
||||
var spawnedFinalRoom = TrySpawnRoom(MapTheme.Rooms.Where(x => x.Type == offshootTypeToSpawn).ToList(),
|
||||
lastSpawnedOffshootRoom, direction);
|
||||
|
||||
if (spawnedFinalRoom is null)
|
||||
|
|
@ -406,6 +407,7 @@ public partial class RogueliteRoomManager : Node2D
|
|||
var roomScene = GD.Load<PackedScene>(room.ScenePath);
|
||||
var spawnedScene = this.CreateChild<RogueliteRoom>(roomScene, position);
|
||||
|
||||
spawnedScene.MapTheme = MapTheme;
|
||||
spawnedScene.GridPosition = gridPos;
|
||||
|
||||
spawnedScene.Name = room.RoomName.ToString().Replace(" ", "_");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue