Implement boss room
This commit is contained in:
23
src/map/dungeon/floors/BossFloor.cs
Normal file
23
src/map/dungeon/floors/BossFloor.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class BossFloor : Node3D, IDungeonFloor
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
private BossRoom BossRoom;
|
||||
|
||||
public void InitializeDungeon()
|
||||
{
|
||||
var bossRoomScene = GD.Load<PackedScene>($"res://src/map/dungeon/scenes/BossRoom.tscn");
|
||||
BossRoom = bossRoomScene.Instantiate<BossRoom>();
|
||||
AddChild(BossRoom);
|
||||
}
|
||||
|
||||
public Transform3D GetPlayerSpawnPoint() => BossRoom.PlayerSpawn.GlobalTransform;
|
||||
|
||||
public Vector3 GetTeleportSpawnPoint() => BossRoom.TeleportSpawn.GlobalPosition;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public interface IDungeonFloor : INode3D
|
||||
{
|
||||
void InitializeDungeon();
|
||||
|
||||
public Vector3 GetPlayerSpawnPoint();
|
||||
public Transform3D GetPlayerSpawnPoint();
|
||||
|
||||
public Vector3 GetTeleportSpawnPoint();
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
|
||||
|
||||
[Node] public GodotObject DungeonGenerator { get; set; } = default!;
|
||||
|
||||
private Vector3 _playerSpawnPoint;
|
||||
private Transform3D _playerSpawnPoint;
|
||||
|
||||
private Vector3 _teleportSpawnPoint;
|
||||
|
||||
@@ -33,14 +33,14 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
|
||||
DungeonGenerator.Call("generate");
|
||||
Rooms = FindAllDungeonRooms([.. GetChildren()], Rooms);
|
||||
_playerSpawnPoint = RandomizePlayerSpawnPoint();
|
||||
_teleportSpawnPoint = RandomizeTeleportSpawnPointAwayFromPosition(_playerSpawnPoint);
|
||||
_teleportSpawnPoint = RandomizeTeleportSpawnPointAwayFromPosition(_playerSpawnPoint.Origin);
|
||||
}
|
||||
|
||||
public Vector3 GetPlayerSpawnPoint() => _playerSpawnPoint;
|
||||
public Transform3D GetPlayerSpawnPoint() => _playerSpawnPoint;
|
||||
|
||||
public Vector3 GetTeleportSpawnPoint() => _teleportSpawnPoint;
|
||||
|
||||
private Vector3 RandomizePlayerSpawnPoint()
|
||||
private Transform3D RandomizePlayerSpawnPoint()
|
||||
{
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
@@ -49,7 +49,7 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
|
||||
.Select(x => x.PlayerSpawn);
|
||||
var godotCollection = new Godot.Collections.Array<Marker3D>(randomSpawnLocations);
|
||||
var result = godotCollection.PickRandom();
|
||||
return result.GlobalPosition;
|
||||
return result.GlobalTransform;
|
||||
}
|
||||
|
||||
private Vector3 RandomizeTeleportSpawnPointAwayFromPosition(Vector3 target)
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://bc1sp6xwe0j65"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonGenerator3D.gd" id="1_sr15j"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpec2lbt83dhe" path="res://src/map/dungeon/scenes/Antechamber.tscn" id="3_hhw2n"]
|
||||
[ext_resource type="PackedScene" uid="uid://bn4gslp2gk8ds" path="res://src/map/dungeon/corridor/Corridor.tscn" id="4_pgrs5"]
|
||||
[ext_resource type="Script" path="res://src/map/dungeon/floors/DungeonFloor.cs" id="5_bsukb"]
|
||||
[ext_resource type="Script" path="res://src/map/dungeon/floors/DungeonFloor.cs" id="1_0ecnn"]
|
||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonGenerator3D.gd" id="2_cxmwa"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpec2lbt83dhe" path="res://src/map/dungeon/scenes/Antechamber.tscn" id="3_tsw3y"]
|
||||
[ext_resource type="PackedScene" uid="uid://bn4gslp2gk8ds" path="res://src/map/dungeon/corridor/Corridor.tscn" id="4_gni6i"]
|
||||
|
||||
[node name="Floor1" type="Node3D"]
|
||||
script = ExtResource("5_bsukb")
|
||||
script = ExtResource("1_0ecnn")
|
||||
|
||||
[node name="DungeonGenerator" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("1_sr15j")
|
||||
room_scenes = Array[PackedScene]([ExtResource("3_hhw2n")])
|
||||
corridor_room_scene = ExtResource("4_pgrs5")
|
||||
script = ExtResource("2_cxmwa")
|
||||
room_scenes = Array[PackedScene]([ExtResource("3_tsw3y")])
|
||||
corridor_room_scene = ExtResource("4_gni6i")
|
||||
dungeon_size = Vector3i(20, 1, 20)
|
||||
voxel_scale = Vector3(4.12, 4, 4)
|
||||
voxel_scale = Vector3(4, 4, 4)
|
||||
generate_on_ready = false
|
||||
place_even_if_fail = true
|
||||
6
src/map/dungeon/floors/Floor11.tscn
Normal file
6
src/map/dungeon/floors/Floor11.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://g28xmp6cn16h"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/map/dungeon/floors/BossFloor.cs" id="1_gsbuk"]
|
||||
|
||||
[node name="Floor11" type="Node3D"]
|
||||
script = ExtResource("1_gsbuk")
|
||||
@@ -19,9 +19,9 @@ public partial class Overworld : Node3D, IDungeonFloor
|
||||
{
|
||||
}
|
||||
|
||||
public Vector3 GetPlayerSpawnPoint()
|
||||
public Transform3D GetPlayerSpawnPoint()
|
||||
{
|
||||
return PlayerSpawnPoint.GlobalPosition;
|
||||
return PlayerSpawnPoint.GlobalTransform;
|
||||
}
|
||||
|
||||
public Vector3 GetTeleportSpawnPoint()
|
||||
|
||||
Reference in New Issue
Block a user