mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-05 17:21:17 +00:00
Fixed spawn offset generation
This commit is contained in:
parent
13ac8e4f2f
commit
8c20e6f342
6 changed files with 182 additions and 40 deletions
17
Resources/RogueliteMaps/BigLarge.tres
Normal file
17
Resources/RogueliteMaps/BigLarge.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[gd_resource type="Resource" script_class="RogueliteRoomResource" load_steps=6 format=3 uid="uid://n6nb5yco60gi"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://cocl3qontm3be" path="res://Resources/Enemies/Base_Fairy.tres" id="1_ch23e"]
|
||||
[ext_resource type="Resource" uid="uid://cqfyuurvqb8m6" path="res://Resources/Enemies/Base_Fairy_Special.tres" id="2_l64su"]
|
||||
[ext_resource type="Resource" uid="uid://qbo6avc7x64b" path="res://Resources/Enemies/Fairy_Guard.tres" id="3_0b7uq"]
|
||||
[ext_resource type="Resource" uid="uid://cfdvg162u65sr" path="res://Resources/Enemies/Thermathron.tres" id="4_iwrey"]
|
||||
[ext_resource type="Script" uid="uid://bl2ne8w12e3a" path="res://Scripts/Resources/Roguelite/RogueliteRoomResource.cs" id="5_yivs1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("5_yivs1")
|
||||
RoomName = &"Test"
|
||||
Type = 1
|
||||
ScenePath = &"uid://c3x64n451f3mk"
|
||||
Size = Vector2i(3, 2)
|
||||
DoorGridPositions = Array[Vector2i]([Vector2i(0, -1), Vector2i(0, 1), Vector2i(1, 0), Vector2i(-1, 0)])
|
||||
SpawnableEnemies = Array[Object]([ExtResource("1_ch23e"), ExtResource("2_l64su"), ExtResource("3_0b7uq"), ExtResource("4_iwrey")])
|
||||
metadata/_custom_type_script = "uid://bl2ne8w12e3a"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=20 format=3 uid="uid://bf1kqr3o6r6d4"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://bf1kqr3o6r6d4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_wbqvu"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_3fyis"]
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
[ext_resource type="Resource" uid="uid://cmgiqsmujujss" path="res://Resources/RogueliteMaps/TestMapLongX3.tres" id="12_83bvc"]
|
||||
[ext_resource type="Script" uid="uid://cnkipcolyj61w" path="res://Scripts/AlarmManager.cs" id="12_eoca5"]
|
||||
[ext_resource type="PackedScene" uid="uid://b3tyacxxw88lx" path="res://Scenes/Utils/StreamPlayerWithName.tscn" id="13_4n7t6"]
|
||||
[ext_resource type="Resource" uid="uid://n6nb5yco60gi" path="res://Resources/RogueliteMaps/BigLarge.tres" id="13_y651a"]
|
||||
[ext_resource type="Script" uid="uid://3v6q0p5krqn7" path="res://Scripts/UI/Minimap.cs" id="16_pfafs"]
|
||||
|
||||
[node name="GameScene" type="Node2D"]
|
||||
|
|
@ -32,7 +33,7 @@ SpawnMarkers = Dictionary[int, NodePath]({
|
|||
[node name="Maps" type="Node2D" parent="." groups=["navigation_polygon_source_geometry_group"]]
|
||||
process_mode = 1
|
||||
script = ExtResource("4_jtlua")
|
||||
Rooms = Array[Object]([ExtResource("5_gwtv6"), ExtResource("6_gwtv6"), ExtResource("7_wbqvu"), ExtResource("8_3fyis"), ExtResource("9_go1yg"), ExtResource("5_pfafs"), ExtResource("11_68lig"), ExtResource("12_83bvc")])
|
||||
Rooms = Array[Object]([ExtResource("5_gwtv6"), ExtResource("6_gwtv6"), ExtResource("7_wbqvu"), ExtResource("8_3fyis"), ExtResource("9_go1yg"), ExtResource("5_pfafs"), ExtResource("11_68lig"), ExtResource("12_83bvc"), ExtResource("13_y651a")])
|
||||
|
||||
[node name="CameraController" type="Camera2D" parent="."]
|
||||
process_mode = 1
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ position = Vector2(159, 23)
|
|||
script = ExtResource("5_mqiea")
|
||||
|
||||
[node name="South" type="Marker2D" parent="Doors"]
|
||||
position = Vector2(159.196, 149.348)
|
||||
position = Vector2(159, 160)
|
||||
script = ExtResource("5_mqiea")
|
||||
Direction = 1
|
||||
|
||||
|
|
|
|||
104
Scenes/Maps/RogueliteMaps/RgBigLarge.tscn
Normal file
104
Scenes/Maps/RogueliteMaps/RgBigLarge.tscn
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -31,12 +31,13 @@ public partial class RogueliteRoomManager : Node2D
|
|||
[Export] public int DungeonWidth = 10;
|
||||
[Export] public int DungeonHeight = 10;
|
||||
[Export] public int MaxRooms = 12;
|
||||
//[Export] public int Seed = -1;
|
||||
[Export] public ulong Seed = 0;
|
||||
|
||||
[Export] public Vector2I TileSize { get; set; } = new Vector2I(16, 16);
|
||||
[Export] public Vector2I RoomSizeInTiles { get; set; } = new Vector2I(20, 10);
|
||||
|
||||
[Signal] public delegate void MapCreatedEventHandler();
|
||||
[Signal]
|
||||
public delegate void MapCreatedEventHandler();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -79,6 +80,11 @@ public partial class RogueliteRoomManager : Node2D
|
|||
|
||||
private void GenerateStraightLineDungeon()
|
||||
{
|
||||
if (Seed > 0)
|
||||
{
|
||||
GD.Seed(Seed);
|
||||
}
|
||||
|
||||
Vector2I origin = Vector2I.Zero;
|
||||
var starterRoom = Rooms.Where(r => r.Type == RoomType.Starter).PickRandom();
|
||||
SpawnRoom(starterRoom, origin);
|
||||
|
|
@ -87,6 +93,7 @@ public partial class RogueliteRoomManager : Node2D
|
|||
var randomRoomsList = RegularRooms.Shuffle(DungeonLength).ToList();
|
||||
|
||||
var currentPos = origin;
|
||||
_connections.Add(new RoomConnection(origin, currentPos + new Vector2I(0, 1)));
|
||||
Vector2I nextPos;
|
||||
|
||||
for (int i = 0; i < DungeonLength; i++)
|
||||
|
|
@ -96,6 +103,11 @@ public partial class RogueliteRoomManager : Node2D
|
|||
//var roomToSpawn = Rooms.Where(x => x.Type == RoomType.Regular).PickRandom();
|
||||
var roomToSpawn = randomRoomsList[i];
|
||||
|
||||
// First pick a random door on the from room
|
||||
//var doorOffset = Math.Min(0, GD.RandRange(0, currentRoom.Size.X - 1));
|
||||
|
||||
// We're already in the new room position, we do not care about previous anymore
|
||||
|
||||
var offset = 0;
|
||||
|
||||
// Place it at a random X position
|
||||
|
|
@ -104,27 +116,34 @@ public partial class RogueliteRoomManager : Node2D
|
|||
offset -= GD.RandRange(0, roomToSpawn.Size.X - 1);
|
||||
}
|
||||
|
||||
var posWithOffset = new Vector2I(offset, nextPos.Y);
|
||||
nextPos += new Vector2I(offset, 0);
|
||||
|
||||
if (!SpawnRoom(roomToSpawn, posWithOffset))
|
||||
//var posWithOffset = nextPos + new Vector2I(offset, 0);
|
||||
|
||||
if (!SpawnRoom(roomToSpawn, nextPos))
|
||||
{
|
||||
GD.PrintErr("Could not spawn room");
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
_mainPath.Add(posWithOffset);
|
||||
;
|
||||
|
||||
_mainPath.Add(nextPos);
|
||||
|
||||
// Place cursor at bottom of room
|
||||
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));
|
||||
var exit = GD.RandRange(0, roomToSpawn.Size.X - 1);
|
||||
if (exit < 0) exit = 0;
|
||||
|
||||
nextPos += new Vector2I(0, exit);
|
||||
nextPos += new Vector2I(exit, 0);
|
||||
// nextPos is now the end of the room at the current exit
|
||||
|
||||
_connections.Add(new RoomConnection(currentPos, nextPos));
|
||||
_connections.Add(new RoomConnection(nextPos, nextPos + new Vector2I(0, 1)));
|
||||
//+ new Vector2I(0, roomToSpawn.Size.Y -1)
|
||||
// Reset X offset
|
||||
//nextPos = new Vector2I(0, nextPos.Y);
|
||||
|
|
|
|||
1
Scripts/Utils/ShuffleExtensions.cs.uid
Normal file
1
Scripts/Utils/ShuffleExtensions.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cayi15oyskn85
|
||||
Loading…
Add table
Add a link
Reference in a new issue