Improvements to save and loading
Improvements to Chinthe animation logic Fix broken Godot Tool system and just use a more manual approach to setting map nodes Remove ItemDatabase from individual room scenes
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using static SpecialFloorLayout;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -9,41 +8,48 @@ public static class LayoutToScenePathConverter
|
||||
{
|
||||
private static readonly string _folderPath = "res://src/map/dungeon/floors";
|
||||
|
||||
public static string Convert(LayoutType layoutType)
|
||||
public static string Convert(FloorNode floorNode)
|
||||
{
|
||||
if (layoutType is SpecialFloorLayout specialFloor)
|
||||
{
|
||||
var path = $"{_folderPath}/Special Floors/";
|
||||
var files = DirAccess.GetFilesAt(path);
|
||||
switch (specialFloor.FloorName)
|
||||
{
|
||||
case SpecialFloorType.Overworld:
|
||||
return path + files.Single(x => x.Contains("Overworld.tscn"));
|
||||
case SpecialFloorType.Altar:
|
||||
return path + files.Single(x => x.Contains("Altar.tscn"));
|
||||
case SpecialFloorType.BossFloorA:
|
||||
return path + files.Single(x => x.Contains("Boss Floor A.tscn"));
|
||||
case SpecialFloorType.BossFloorB:
|
||||
return path + files.Single(x => x.Contains("Boss Floor B.tscn"));
|
||||
case SpecialFloorType.GoddessOfGuidanceFloor:
|
||||
return path + files.Single(x => x.Contains("Goddess of Guidance's Room.tscn"));
|
||||
case SpecialFloorType.TrueGoddessOfGuidanceFloor:
|
||||
return path + files.Single(x => x.Contains("Goddess of Guidance's Room - True Form.tscn"));
|
||||
case SpecialFloorType.FinalFloor:
|
||||
return path + files.Single(x => x.Contains("Final Floor.tscn"));
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
else if (layoutType is DungeonFloorLayout dungeonFloor)
|
||||
{
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var index = (int)rng.RandWeighted([.. dungeonFloor.LayoutWithSpawnRate.Values]);
|
||||
var result = dungeonFloor.LayoutWithSpawnRate.ElementAt(index);
|
||||
return _folderPath + "/" + result.Key;
|
||||
}
|
||||
|
||||
if (floorNode is DungeonFloorNode dungeonFloorNode)
|
||||
return RandomDungeonFloor(dungeonFloorNode);
|
||||
else if (floorNode is SpecialFloorNode specialFloorNode)
|
||||
return SpawnSpecialFloor(specialFloorNode.FloorName);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static string SpawnSpecialFloor(SpecialFloorType floorType)
|
||||
{
|
||||
var path = $"{_folderPath}/Special Floors/";
|
||||
var files = DirAccess.GetFilesAt(path);
|
||||
switch (floorType)
|
||||
{
|
||||
case SpecialFloorType.Overworld:
|
||||
return path + files.Single(x => x.Contains("Overworld.tscn"));
|
||||
case SpecialFloorType.Altar:
|
||||
return path + files.Single(x => x.Contains("Altar.tscn"));
|
||||
case SpecialFloorType.BossFloorA:
|
||||
return path + files.Single(x => x.Contains("Boss Floor A.tscn"));
|
||||
case SpecialFloorType.BossFloorB:
|
||||
return path + files.Single(x => x.Contains("Boss Floor B.tscn"));
|
||||
case SpecialFloorType.GoddessOfGuidanceFloor:
|
||||
return path + files.Single(x => x.Contains("Goddess of Guidance's Room.tscn"));
|
||||
case SpecialFloorType.TrueGoddessOfGuidanceFloor:
|
||||
return path + files.Single(x => x.Contains("Goddess of Guidance's Room - True Form.tscn"));
|
||||
case SpecialFloorType.FinalFloor:
|
||||
return path + files.Single(x => x.Contains("Final Floor.tscn"));
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private static string RandomDungeonFloor(DungeonFloorNode floorNode)
|
||||
{
|
||||
var folderName = _folderPath + "/" + floorNode.FolderName;
|
||||
var floorList = DirAccess.GetFilesAt(folderName).Where(x => x.EndsWith(".tscn"));
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var index = (int)rng.RandWeighted([.. floorNode.FloorOdds]);
|
||||
var result = floorList.ElementAt(index);
|
||||
return folderName + "/" + result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user