2024-05-07 09:38:50 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
using ColdMint.scripts.inventory;
|
|
|
|
|
using ColdMint.scripts.map;
|
2024-05-19 14:32:34 +00:00
|
|
|
|
using ColdMint.scripts.map.LayoutParsingStrategy;
|
|
|
|
|
using ColdMint.scripts.map.layoutStrategy;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
using ColdMint.scripts.map.RoomPlacer;
|
2024-05-21 14:50:33 +00:00
|
|
|
|
using ColdMint.scripts.utils;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.loader.sceneLoader;
|
|
|
|
|
|
|
|
|
|
public partial class GameSceneLoader : SceneLoaderTemplate
|
|
|
|
|
{
|
2024-05-23 13:58:49 +00:00
|
|
|
|
private Label? _seedLabel;
|
|
|
|
|
|
2024-05-07 11:36:06 +00:00
|
|
|
|
public override Task InitializeData()
|
2024-05-07 09:38:50 +00:00
|
|
|
|
{
|
|
|
|
|
//加载血条场景
|
2024-05-07 11:36:06 +00:00
|
|
|
|
var healthBarUi = GetNode<HealthBarUi>("CanvasLayer/Control/VBoxContainer/HealthBarUi");
|
|
|
|
|
GameSceneNodeHolder.HealthBarUi = healthBarUi;
|
2024-05-07 09:38:50 +00:00
|
|
|
|
//加载HotBar
|
|
|
|
|
var hotBar = GetNode<HotBar>("CanvasLayer/Control/VBoxContainer/HotBar");
|
|
|
|
|
GameSceneNodeHolder.HotBar = hotBar;
|
|
|
|
|
//加载操作提示
|
2024-05-09 13:07:14 +00:00
|
|
|
|
var operationTip = GetNode<RichTextLabel>("CanvasLayer/Control/VBoxContainer/OperationTip");
|
2024-05-07 09:38:50 +00:00
|
|
|
|
GameSceneNodeHolder.OperationTipLabel = operationTip;
|
|
|
|
|
//加载武器容器
|
|
|
|
|
var weaponContainer = GetNode<Node2D>("WeaponContainer");
|
|
|
|
|
GameSceneNodeHolder.WeaponContainer = weaponContainer;
|
2024-05-07 11:36:06 +00:00
|
|
|
|
return Task.CompletedTask;
|
2024-05-07 09:38:50 +00:00
|
|
|
|
}
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
2024-05-07 09:38:50 +00:00
|
|
|
|
public override async Task LoadScene()
|
|
|
|
|
{
|
2024-05-23 13:58:49 +00:00
|
|
|
|
var debugMode = Config.IsDebug();
|
|
|
|
|
var recreateMapButton = GetNodeOrNull<Button>("CanvasLayer/Control/RecreateMapButton");
|
|
|
|
|
if (recreateMapButton != null)
|
|
|
|
|
{
|
|
|
|
|
recreateMapButton.Visible = debugMode;
|
|
|
|
|
recreateMapButton.Pressed += () => { _ = GenerateMap(); };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_seedLabel = GetNodeOrNull<Label>("CanvasLayer/Control/SeedLabel");
|
|
|
|
|
if (_seedLabel != null)
|
|
|
|
|
{
|
|
|
|
|
_seedLabel.Visible = Config.IsDebug();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-20 14:38:41 +00:00
|
|
|
|
MapGenerator.MapRoot = GetNode<Node>("MapRoot");
|
2024-05-19 14:32:34 +00:00
|
|
|
|
MapGenerator.LayoutStrategy = new TestLayoutStrategy();
|
|
|
|
|
MapGenerator.LayoutParsingStrategy = new SequenceLayoutParsingStrategy();
|
2024-05-20 14:38:41 +00:00
|
|
|
|
MapGenerator.RoomPlacementStrategy = new PatchworkRoomPlacementStrategy();
|
2024-05-23 13:58:49 +00:00
|
|
|
|
await GenerateMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>Generate map</para>
|
|
|
|
|
/// <para>生成地图</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async Task GenerateMap()
|
|
|
|
|
{
|
2024-05-24 14:58:52 +00:00
|
|
|
|
//2757235769 房间边框重叠!
|
|
|
|
|
//4175259928 房间内容重叠!
|
|
|
|
|
MapGenerator.Seed = "4175259928";
|
2024-05-23 13:58:49 +00:00
|
|
|
|
if (_seedLabel != null)
|
|
|
|
|
{
|
|
|
|
|
//If you have a seedLabel, then set the seed to it.
|
|
|
|
|
//如果有seedLabel,那么将种子设置上去。
|
2024-05-24 14:58:52 +00:00
|
|
|
|
var seedInfo = TranslationServerUtils.TranslateWithFormat("seed_info", MapGenerator.Seed);
|
|
|
|
|
if (seedInfo == null)
|
|
|
|
|
{
|
|
|
|
|
_seedLabel.Text = $"Seed: {MapGenerator.Seed}";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_seedLabel.Text = seedInfo;
|
|
|
|
|
}
|
2024-05-23 13:58:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-20 14:38:41 +00:00
|
|
|
|
await MapGenerator.GenerateMap();
|
2024-05-07 09:38:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|