Basic projectile implementation (put sample version in FilthEaterModelView)
This commit is contained in:
@@ -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