Add map loading logic and spawn rate control
This commit is contained in:
@@ -36,9 +36,7 @@ public partial class Map : Node3D, IMap
|
||||
#endregion
|
||||
|
||||
[Export]
|
||||
private Array<Floor> Floors { get; set; } = default!;
|
||||
|
||||
public ImmutableDictionary<Floor, string> FloorScenes { get; private set; }
|
||||
private Array<LayoutType> Floors { get; set; } = default!;
|
||||
|
||||
public IDungeonFloor CurrentFloor { get; private set; }
|
||||
|
||||
@@ -57,14 +55,6 @@ public partial class Map : Node3D, IMap
|
||||
|
||||
public void InitializeMapData()
|
||||
{
|
||||
FloorScenes = ImmutableDictionary<Floor, string>.Empty
|
||||
.Add(Floor.Overworld, _floorFilePath + "Special Floors/Overworld.tscn")
|
||||
.Add(Floor.Altar, _floorFilePath + "Special Floors/Altar.tscn")
|
||||
.Add(Floor.BossFloorA, _floorFilePath + "Special Floors/15. Boss Floor A.tscn")
|
||||
.Add(Floor.BossFloorB, _floorFilePath + "Special Floors/34. Boss Floor B.tscn")
|
||||
.Add(Floor.GoddessOfGuidanceFloor, _floorFilePath + "Special Floors/35. Goddess of Guidance's Room.tscn")
|
||||
.Add(Floor.VoidRoom, _floorFilePath + "Set B/30. Void Room.tscn")
|
||||
.Add(Floor.FinalFloor, _floorFilePath + "Special Floors/36. Final Floor.tscn");
|
||||
CurrentFloorNumber.OnNext(0);
|
||||
}
|
||||
|
||||
@@ -79,9 +69,11 @@ public partial class Map : Node3D, IMap
|
||||
|
||||
public async Task LoadFloor()
|
||||
{
|
||||
GetMapFiles();
|
||||
FloorScenes.TryGetValue(Floors.First(), out var sceneToLoad);
|
||||
var floor = GetChildren().OfType<LayoutType>().ElementAt(CurrentFloorNumber.Value);
|
||||
var sceneToLoad = LayoutToScenePathConverter.Convert(floor);
|
||||
await LoadFloor(sceneToLoad);
|
||||
if (CurrentFloor is DungeonFloor dungeonFloor && floor is DungeonFloorLayout dungeonFloorLayout)
|
||||
dungeonFloor.SpawnEnemies(dungeonFloorLayout.EnemySpawnRates);
|
||||
}
|
||||
|
||||
public async Task LoadFloor(string sceneName)
|
||||
@@ -125,10 +117,4 @@ public partial class Map : Node3D, IMap
|
||||
var transform = GetPlayerSpawnPosition();
|
||||
Player.TeleportPlayer(transform);
|
||||
}
|
||||
|
||||
private string[] GetMapFiles()
|
||||
{
|
||||
var folderLocation = _floorFilePath + "Floor" + CurrentFloorNumber.Value.ToString("D2");
|
||||
return DirAccess.GetFilesAt(folderLocation);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user