Horizontal offsets

This commit is contained in:
Marco 2025-04-15 16:22:30 +02:00
commit bbdba6ae6d
7 changed files with 168 additions and 10 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Cirno.Scripts.Enums;
using Cirno.Scripts.Resources.Roguelite;
@ -92,18 +93,40 @@ public partial class RogueliteRoomManager : Node2D
//var roomToSpawn = Rooms.Where(x => x.Type == RoomType.Regular).PickRandom();
var roomToSpawn = randomRoomsList[i];
if (!SpawnRoom(roomToSpawn, nextPos)) break;
_mainPath.Add(nextPos);
var offset = 0;
// Place it at a random X position
if (roomToSpawn.Size.X > 1)
{
offset -= GD.RandRange(0, roomToSpawn.Size.X - 1);
}
var posWithOffset = new Vector2I(offset, nextPos.Y);
if (!SpawnRoom(roomToSpawn, posWithOffset))
{
GD.PrintErr("Could not spawn room");
break;
};
_mainPath.Add(posWithOffset);
if (roomToSpawn.Size.Y > 1)
{
nextPos += new Vector2I(0, roomToSpawn.Size.Y - 1);
}
// Pick a random exit to continue
var exit = Math.Min(0, GD.RandRange(0, roomToSpawn.Size.X - 1));
nextPos += new Vector2I(0, exit);
_connections.Add(new RoomConnection(currentPos, nextPos));
// Reset X offset
//nextPos = new Vector2I(0, nextPos.Y);
currentPos = nextPos;
}
@ -122,6 +145,10 @@ public partial class RogueliteRoomManager : Node2D
_connections.Add(new RoomConnection(currentPos, nextPos));
}
else
{
GD.PrintErr("Could not spawn boss room");
}
foreach (var roomEntry in _roomGrid)
{