diff --git a/Resources/RogueliteMaps/Factory_Theme.tres b/Resources/RogueliteMaps/Factory_Theme.tres index 98eff4bb..ff2b35fe 100644 --- a/Resources/RogueliteMaps/Factory_Theme.tres +++ b/Resources/RogueliteMaps/Factory_Theme.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="RogueliteMapTheme" load_steps=49 format=3 uid="uid://cw6868vuvuynh"] +[gd_resource type="Resource" script_class="RogueliteMapTheme" load_steps=51 format=3 uid="uid://cw6868vuvuynh"] [ext_resource type="Script" uid="uid://bwtif3if3ea0u" path="res://Scripts/Resources/RogueliteMapTheme.cs" id="1_2rtdw"] [ext_resource type="Resource" uid="uid://cltxhkrqp055v" path="res://Resources/Items/Money_Pickup.tres" id="1_ae3bb"] @@ -6,7 +6,6 @@ [ext_resource type="PackedScene" uid="uid://db5dwj6nqo8fn" path="res://Scenes/Interactable/control_pad_gray_keycard.tscn" id="1_w43eq"] [ext_resource type="Resource" uid="uid://oa8s6xydriib" path="res://Resources/Items/Generic_Keycard.tres" id="2_p3lfl"] [ext_resource type="PackedScene" uid="uid://l84on3kv2s52" path="res://Scenes/Door_Horizontal.tscn" id="2_y7x1u"] -[ext_resource type="PackedScene" uid="uid://bs6o3htusgyjl" path="res://Scenes/Door_Horizontal_Hidden.tscn" id="3_sdu6a"] [ext_resource type="Resource" uid="uid://dodwpect0ldjf" path="res://Resources/Items/Heart_Pickup.tres" id="3_tsgja"] [ext_resource type="PackedScene" uid="uid://mtn26qwp4yqy" path="res://Scenes/Items/Gray_Keycard.tscn" id="4_qjf5s"] [ext_resource type="Resource" uid="uid://bhbufxodybsw4" path="res://Resources/Items/Shield_Pickup.tres" id="4_qo6vk"] @@ -29,7 +28,9 @@ [ext_resource type="Script" uid="uid://rgx0g5iqksnn" path="res://Scripts/Resources/Loot/LootTable.cs" id="11_eegnh"] [ext_resource type="Resource" uid="uid://do11fodskgasi" path="res://Resources/RogueliteMaps/RGTestRoom1.tres" id="14_rjphh"] [ext_resource type="Resource" uid="uid://cur433g6oevmd" path="res://Resources/RogueliteMaps/RGLongAcidWalk.tres" id="15_2gg5d"] +[ext_resource type="PackedScene" uid="uid://bi6m7am6gry17" path="res://Scenes/Misc/Horizontal_North_Solid_Wall.tscn" id="15_qo6vk"] [ext_resource type="Resource" uid="uid://cc53bb6th33hi" path="res://Resources/RogueliteMaps/RGHorizontal1x1.tres" id="16_402ix"] +[ext_resource type="PackedScene" uid="uid://q5mj5fqxy0dv" path="res://Scenes/Misc/Horizontal_South_Solid_Wall.tscn" id="16_ga54h"] [ext_resource type="Resource" uid="uid://bew4cuec4pbms" path="res://Resources/RogueliteMaps/KeyRoom1.tres" id="17_52l5g"] [ext_resource type="Resource" uid="uid://cwtma7mxged8a" path="res://Resources/RogueliteMaps/ShopRoom1.tres" id="18_gh41q"] [ext_resource type="Resource" uid="uid://crqgvauqarfaq" path="res://Resources/RogueliteMaps/TreasureRoom1.tres" id="19_bn1n6"] @@ -37,6 +38,7 @@ [ext_resource type="Resource" uid="uid://bxvv82vno8ub1" path="res://Resources/RogueliteMaps/1x1_1.tres" id="23_p3lfl"] [ext_resource type="Resource" uid="uid://d01146n5uo0gd" path="res://Resources/RogueliteMaps/1x2_1.tres" id="24_tsgja"] [ext_resource type="PackedScene" uid="uid://cl7s06sk106uo" path="res://Scenes/Props/VendingMachine.tscn" id="30_exyjy"] +[ext_resource type="PackedScene" uid="uid://dff3lrk4srymb" path="res://Scenes/Misc/Vertical_Solid_Wall.tscn" id="40_tsgja"] [ext_resource type="Resource" uid="uid://bdpbekqhuuq4l" path="res://Resources/Items/Shield_Extend_Pickup.tres" id="41_tsgja"] [ext_resource type="Resource" uid="uid://ciybnocjfpshh" path="res://Resources/Items/Heart_Extend_Pickup.tres" id="42_qo6vk"] [ext_resource type="PackedScene" uid="uid://c21m7w5ahpsd0" path="res://Scenes/Activable/Shroud.tscn" id="43_3kwn2"] @@ -70,9 +72,10 @@ script = ExtResource("1_2rtdw") TileSize = Vector2i(16, 16) RoomSizeInTiles = Vector2i(20, 10) HorizontalDoorPrefab = ExtResource("2_y7x1u") -HorizontalWallPrefab = ExtResource("3_sdu6a") +HorizontalNorthWallPrefab = ExtResource("15_qo6vk") +HorizontalSouthWallPrefab = ExtResource("16_ga54h") VerticalDoorPrefab = ExtResource("5_mt0fe") -VerticalWallPrefab = ExtResource("5_mt0fe") +VerticalWallPrefab = ExtResource("40_tsgja") DoorLockPrefab = ExtResource("1_w43eq") KeyCardPrefab = ExtResource("4_qjf5s") ChestPrefab = ExtResource("1_modrh") diff --git a/Scenes/HUD/HUD.tscn b/Scenes/HUD/HUD.tscn index 70877de3..7b34cae8 100644 --- a/Scenes/HUD/HUD.tscn +++ b/Scenes/HUD/HUD.tscn @@ -411,8 +411,7 @@ expand_mode = 1 stretch_mode = 3 [node name="FPS" type="Label" parent="."] -visible = false -z_index = 10 +z_index = 20 z_as_relative = false anchors_preset = 3 anchor_left = 1.0 diff --git a/Scenes/Maps/RogueliteMaps/RgBig.tscn b/Scenes/Maps/RogueliteMaps/RgBig.tscn index d6b93ebc..a96cc024 100644 --- a/Scenes/Maps/RogueliteMaps/RgBig.tscn +++ b/Scenes/Maps/RogueliteMaps/RgBig.tscn @@ -118,6 +118,7 @@ script = ExtResource("7_cgxuy") Enemy = ExtResource("9_tyndx") [node name="NavigationRegion2D" type="NavigationRegion2D" parent="."] +visible = false navigation_polygon = SubResource("NavigationPolygon_lrgk6") [node name="PlayerEnterDetector" type="Area2D" parent="."] diff --git a/Scenes/Misc/Horizontal_North_Solid_Wall.tscn b/Scenes/Misc/Horizontal_North_Solid_Wall.tscn new file mode 100644 index 00000000..2e9e9816 --- /dev/null +++ b/Scenes/Misc/Horizontal_North_Solid_Wall.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=4 uid="uid://bi6m7am6gry17"] + +[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="1_vyess"] + +[node name="TileMapLayer" type="TileMapLayer" groups=["Solid"]] +tile_map_data = PackedByteArray("AAD/////AAAKAAgAAAD//wAAAAAKAAkAAAAAAP//AAAKAAgAAAAAAAAAAAAKAAkAAAABAP//AAAKAAgAAAABAAAAAAAKAAkAAAD+////AAAKAAgAAAD+/wAAAAAKAAkAAAD+//7/AAABAAQAAAD///7/AAABAAQAAAAAAP7/AAABAAQAAAABAP7/AAABAAQAAAA=") +tile_set = ExtResource("1_vyess") diff --git a/Scenes/Misc/Horizontal_South_Solid_Wall.tscn b/Scenes/Misc/Horizontal_South_Solid_Wall.tscn new file mode 100644 index 00000000..b4167469 --- /dev/null +++ b/Scenes/Misc/Horizontal_South_Solid_Wall.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://q5mj5fqxy0dv"] + +[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="1_pohia"] + +[node name="TileMapLayer" type="TileMapLayer" groups=["Solid"]] +z_index = 1 +tile_map_data = PackedByteArray(0, 0, 254, 255, 255, 255, 0, 0, 1, 0, 4, 0, 0, 0, 255, 255, 255, 255, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 255, 255, 0, 0, 1, 0, 4, 0, 0, 0, 1, 0, 255, 255, 0, 0, 1, 0, 4, 0, 0, 0) +tile_set = ExtResource("1_pohia") diff --git a/Scenes/Misc/Vertical_Solid_Wall.tscn b/Scenes/Misc/Vertical_Solid_Wall.tscn new file mode 100644 index 00000000..96f2279c --- /dev/null +++ b/Scenes/Misc/Vertical_Solid_Wall.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://dff3lrk4srymb"] + +[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="1_m2u8i"] + +[node name="TileMapLayer" type="TileMapLayer" groups=["Solid"]] +z_index = 1 +tile_map_data = PackedByteArray(0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 254, 255, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 0, 0, 0) +tile_set = ExtResource("1_m2u8i") diff --git a/Scripts/Controllers/RogueliteRoom.cs b/Scripts/Controllers/RogueliteRoom.cs index 710884b4..e04b125d 100644 --- a/Scripts/Controllers/RogueliteRoom.cs +++ b/Scripts/Controllers/RogueliteRoom.cs @@ -20,7 +20,7 @@ namespace Cirno.Scripts.Controllers; public partial class RogueliteRoom : Node2D { [Export] public RogueliteRoomResource RoomResource { get; set; } - + public RogueliteMapTheme MapTheme { get; set; } public Vector2I GridPosition { get; set; } // Set by dungeon manager @@ -31,7 +31,7 @@ public partial class RogueliteRoom : Node2D private Vector2 BaseRoomSize => MapTheme.TileSize * MapTheme.RoomSizeInTiles; public Vector2 RoomSize => BaseRoomSize * RoomResource.Size; - + public Vector2I RandomBottomExit() { return BottomLeft + new Vector2I(GD.RandRange(0, RoomResource.Size.X - 1), 0); @@ -63,7 +63,7 @@ public partial class RogueliteRoom : Node2D private List _enemies = []; private Array SpawnableEnemies => RoomResource.SpawnableEnemies; - + private BlackCover _shroud; private bool _firstEnter = true; @@ -165,42 +165,40 @@ public partial class RogueliteRoom : Node2D var connection = connectionChecker.Invoke(doorEdge, neighborPos); var connected = connection is not null; - - - var door = this.CreateChildOf(marker, marker.Direction switch - { - DoorDirections.North => MapTheme.HorizontalDoorPrefab, - DoorDirections.South => MapTheme.HorizontalDoorPrefab, - DoorDirections.East => MapTheme.VerticalDoorPrefab, - DoorDirections.West => MapTheme.VerticalDoorPrefab, - _ => throw new ArgumentOutOfRangeException() - }, marker.GlobalPosition); - - door.Close(); - - // door.State = DoorState.Closed; if (connected) { + var door = this.CreateChildOf(marker, marker.Direction switch + { + DoorDirections.North => MapTheme.HorizontalDoorPrefab, + DoorDirections.South => MapTheme.HorizontalDoorPrefab, + DoorDirections.East => MapTheme.VerticalDoorPrefab, + DoorDirections.West => MapTheme.VerticalDoorPrefab, + _ => throw new ArgumentOutOfRangeException() + }, marker.GlobalPosition); + + door.Close(); + + // door.State = DoorState.Closed; + _doors.Add(door); if (doorEdge == connection.From) { connection.FromDoor = door; - + // Spawn lock if locked if (connection.IsLocked) { var doorLock = door.CreateChild(MapTheme.DoorLockPrefab); doorLock.Connection = connection; - + doorLock.ZIndex += 2; //doorLock.Targets.Add(door); //doorLock.Targets.Add(connection.ToDoor); doorLock.ActivationType = ActivationType.Open; } - } else if (doorEdge == connection.To) { @@ -213,12 +211,29 @@ public partial class RogueliteRoom : Node2D } _connections.Add(connection); - } else { - // var wall = this.CreateChild(WallPrefab, marker.GlobalPosition); + // Move marker based on direction + var newMarkerPosition = marker.Direction switch + { + DoorDirections.East => marker.GlobalPosition + new Vector2(-4,0), + DoorDirections.West => marker.GlobalPosition + new Vector2(-12,0), + DoorDirections.North => marker.GlobalPosition + new Vector2(0,0), + DoorDirections.South => marker.GlobalPosition + new Vector2(0,-2), + _ => marker.GlobalPosition + }; + + marker.GlobalPosition = newMarkerPosition; + var wall = this.CreateChildOf(marker, marker.Direction switch + { + DoorDirections.North => MapTheme.HorizontalNorthWallPrefab, + DoorDirections.South => MapTheme.HorizontalSouthWallPrefab, + DoorDirections.East => MapTheme.VerticalWallPrefab, + DoorDirections.West => MapTheme.VerticalWallPrefab, + _ => throw new ArgumentOutOfRangeException() + }, marker.GlobalPosition); } } } @@ -234,7 +249,7 @@ public partial class RogueliteRoom : Node2D if (marker is not RogueliteEnemySpawner spawner) continue; var spawnedEnemy = spawner.Spawn(MapTheme); - + _enemies.Add(spawnedEnemy); spawnedEnemy.Death += SpawnedEnemyOnDeath; @@ -245,13 +260,13 @@ public partial class RogueliteRoom : Node2D { var markersContainer = this.GetNodeOrNull("Treasures"); if (markersContainer == null) return; - + var markerNodes = markersContainer.GetChildren(); - + var itemsPool = MapTheme.WeaponsLootTable.Items.ToList().Shuffle().ToList(); - + var playerItems = InventoryManager.Instance.Items; - + foreach (var itemContainer in playerItems) { if (itemsPool.Contains(itemContainer.Item)) @@ -265,26 +280,26 @@ public partial class RogueliteRoom : Node2D GD.Print("No items to spawn in the item room found"); return; } - + Queue spawnQueue = new(); foreach (var item in itemsPool) { spawnQueue.Enqueue(item); } - + foreach (var markerNode in markerNodes) { if (markerNode is not Marker2D marker) { continue; } - + var itemFound = spawnQueue.TryDequeue(out var item); - + if (!itemFound) return; GD.Print($"Spawning {item.ItemKey} in treasure spot"); - + // Spawn var dropScene = GD.Load(item.DropScenePath); var dropInstance = marker.CreateChild(dropScene); @@ -296,7 +311,7 @@ public partial class RogueliteRoom : Node2D // Get feature markers // Roll for chances // Spawn the objects - + var markersContainer = this.GetNodeOrNull("Features"); if (markersContainer is null) return; @@ -308,18 +323,17 @@ public partial class RogueliteRoom : Node2D { continue; } - + double chance = GD.RandRange(0d, 100d); if (chance <= MapTheme.ChestChance) { var chest = marker.CreateChild(MapTheme.ChestPrefab); var loot = MapTheme.ChestLootTable.Items.ToList().Shuffle().First(); - + chest.LootTable.Add(loot); } } - } private void SpawnedEnemyOnDeath(EnemyFSMProxy enemy) @@ -337,11 +351,12 @@ public partial class RogueliteRoom : Node2D { foreach (var connection in _connections) { - if(!connection.IsLocked) + if (!connection.IsLocked) { connection.FromDoor?.Open(); } - if(!connection.IsLocked) + + if (!connection.IsLocked) { connection.ToDoor?.Open(); } @@ -352,11 +367,12 @@ public partial class RogueliteRoom : Node2D { foreach (var connection in _connections) { - if(!connection.IsLocked) + if (!connection.IsLocked) { connection.FromDoor?.Close(); } - if(!connection.IsLocked) + + if (!connection.IsLocked) { connection.ToDoor?.Close(); } @@ -375,7 +391,7 @@ public partial class RogueliteRoom : Node2D _ = AlarmTriggerAsync(area.GlobalPosition, 1f); } - + // This might cause problems later if I delay enemy spawns if (_enemies.Count <= 0) { @@ -458,12 +474,10 @@ public partial class RogueliteRoom : Node2D if (!RoomResource.StartShrouded) return; var shroud = this.CreateChild(MapTheme.ShroudPrefab); - + shroud.Position = new Vector2(RoomSize.X / 2, RoomSize.Y / 2); shroud.Scale = RoomSize; _shroud = shroud; - } - } \ No newline at end of file diff --git a/Scripts/GameManager.cs b/Scripts/GameManager.cs index 9fe0ae90..fa9a49eb 100644 --- a/Scripts/GameManager.cs +++ b/Scripts/GameManager.cs @@ -8,6 +8,7 @@ using Cirno.Scripts.Misc; using Cirno.Scripts.Resources; using Godot.Collections; using Cirno.Scripts.Utils; +using Environment = Godot.Environment; public partial class GameManager : Node2D { @@ -72,7 +73,7 @@ public partial class GameManager : Node2D public override void _Ready() { Instance = this; - + RenderingServer.SetDefaultClearColor(Colors.Black); GlobalState.Session.LevelNumber = MapResource.LevelId; GlobalState.Instance.ResizeCursor(); diff --git a/Scripts/Resources/RogueliteMapTheme.cs b/Scripts/Resources/RogueliteMapTheme.cs index 23b0d57d..2609c176 100644 --- a/Scripts/Resources/RogueliteMapTheme.cs +++ b/Scripts/Resources/RogueliteMapTheme.cs @@ -15,7 +15,8 @@ public partial class RogueliteMapTheme : Resource [ExportGroup("Prefabs")] [Export] public PackedScene HorizontalDoorPrefab { get; set; } - [Export] public PackedScene HorizontalWallPrefab { get; set; } + [Export] public PackedScene HorizontalNorthWallPrefab { get; set; } + [Export] public PackedScene HorizontalSouthWallPrefab { get; set; } [Export] public PackedScene VerticalDoorPrefab { get; set; } [Export] public PackedScene VerticalWallPrefab { get; set; } [Export] public PackedScene DoorLockPrefab { get; set; }