Basic projectile implementation (put sample version in FilthEaterModelView)
This commit is contained in:
@@ -78,12 +78,6 @@ unique_name_in_owner = true
|
||||
|
||||
[node name="Floor01 (Press Populate Map Data Button to load floor from SetAFloors folder)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("3_v14r0")
|
||||
LayoutWithSpawnRate = Dictionary[String, float]({
|
||||
"SetAFloors/test_floor.tscn": 1.0
|
||||
})
|
||||
EnemySpawnRates = {
|
||||
0: 1.0
|
||||
}
|
||||
metadata/_custom_type_script = "uid://ci7o3nn4mdo8o"
|
||||
|
||||
[node name="Overworld (Add SpecialFloorLayout node for special floors and pick the FloorName from the list)" type="Node" parent="MapOrder"]
|
||||
@@ -92,13 +86,8 @@ metadata/_custom_type_script = "uid://cabvj6s31iucg"
|
||||
|
||||
[node name="Altar (Arrange order of nodes to change default load order)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("2_00xd7")
|
||||
FloorName = 1
|
||||
metadata/_custom_type_script = "uid://cabvj6s31iucg"
|
||||
|
||||
[node name="Floor02 (Add DungeonFloorLayout node for regular dungeon floors)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("3_v14r0")
|
||||
LayoutWithSpawnRate = Dictionary[String, float]({})
|
||||
EnemySpawnRates = {
|
||||
0: 1.0
|
||||
}
|
||||
metadata/_custom_type_script = "uid://ci7o3nn4mdo8o"
|
||||
|
||||
@@ -20,41 +20,41 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
|
||||
|
||||
public void InitializeDungeon()
|
||||
{
|
||||
Rooms = [];
|
||||
Rooms = FindAllDungeonRooms([.. GetChildren()], Rooms);
|
||||
_playerSpawnPoint = RandomizePlayerSpawnPoint();
|
||||
Rooms = [];
|
||||
Rooms = FindAllDungeonRooms([.. GetChildren()], Rooms);
|
||||
_playerSpawnPoint = RandomizePlayerSpawnPoint();
|
||||
}
|
||||
|
||||
public void SpawnEnemies(Godot.Collections.Dictionary<EnemyType, float> enemyInfo)
|
||||
{
|
||||
var monsterRooms = Rooms.OfType<MonsterRoom>();
|
||||
foreach (var room in monsterRooms)
|
||||
room.SpawnEnemies(enemyInfo);
|
||||
var monsterRooms = Rooms.OfType<MonsterRoom>();
|
||||
foreach (var room in monsterRooms)
|
||||
room.SpawnEnemies(enemyInfo);
|
||||
}
|
||||
|
||||
public Transform3D GetPlayerSpawnPoint() => new Transform3D(_playerSpawnPoint.Basis, new Vector3(_playerSpawnPoint.Origin.X, 0f, _playerSpawnPoint.Origin.Z));
|
||||
|
||||
private Transform3D RandomizePlayerSpawnPoint()
|
||||
{
|
||||
var randomSpawnLocations = Rooms
|
||||
.OfType<MonsterRoom>()
|
||||
.Select(x => x.PlayerSpawn);
|
||||
var godotCollection = new Godot.Collections.Array<Marker3D>(randomSpawnLocations);
|
||||
var result = godotCollection.PickRandom();
|
||||
return result.GlobalTransform;
|
||||
var randomSpawnLocations = Rooms
|
||||
.OfType<MonsterRoom>()
|
||||
.Select(x => x.PlayerSpawn);
|
||||
var godotCollection = new Godot.Collections.Array<Marker3D>(randomSpawnLocations);
|
||||
var result = godotCollection.PickRandom();
|
||||
return result.GlobalTransform;
|
||||
}
|
||||
|
||||
private static ImmutableList<IDungeonRoom> FindAllDungeonRooms(List<Node> nodesToSearch, ImmutableList<IDungeonRoom> roomsFound)
|
||||
{
|
||||
if (nodesToSearch.Count == 0)
|
||||
return roomsFound;
|
||||
if (nodesToSearch.Count == 0)
|
||||
return roomsFound;
|
||||
|
||||
foreach (var node in nodesToSearch)
|
||||
{
|
||||
if (node is IDungeonRoom dungeonRoom)
|
||||
roomsFound = roomsFound.Add(dungeonRoom);
|
||||
}
|
||||
foreach (var node in nodesToSearch)
|
||||
{
|
||||
if (node is IDungeonRoom dungeonRoom)
|
||||
roomsFound = roomsFound.Add(dungeonRoom);
|
||||
}
|
||||
|
||||
return FindAllDungeonRooms([.. nodesToSearch.SelectMany(x => x.GetChildren())], roomsFound);
|
||||
return FindAllDungeonRooms([.. nodesToSearch.SelectMany(x => x.GetChildren())], roomsFound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,4 +65,10 @@ public abstract partial class DungeonRoom : Node3D, IDungeonRoom
|
||||
_playerDiscoveredRoom = true;
|
||||
_minimap.Show();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
_room.BodyEntered -= Room_BodyEntered;
|
||||
_room.BodyExited -= Room_BodyExited;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user