连接导航网格中。
This commit is contained in:
parent
9401913779
commit
b0c01cfca0
|
@ -3,22 +3,22 @@ connection_data_list:
|
||||||
to_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
to_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
||||||
from_port: 0
|
from_port: 0
|
||||||
to_port: 0
|
to_port: 0
|
||||||
- from_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
# - from_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
||||||
to_id: ba32e05c-0c80-4a79-b5ce-5b8150400e05
|
# to_id: ba32e05c-0c80-4a79-b5ce-5b8150400e05
|
||||||
from_port: 0
|
# from_port: 0
|
||||||
to_port: 0
|
# to_port: 0
|
||||||
- from_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
# - from_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
||||||
to_id: 8b3d645a-96c0-407e-871d-6f4a0b69557b
|
# to_id: 8b3d645a-96c0-407e-871d-6f4a0b69557b
|
||||||
from_port: 0
|
# from_port: 0
|
||||||
to_port: 0
|
# to_port: 0
|
||||||
- from_id: 8b3d645a-96c0-407e-871d-6f4a0b69557b
|
# - from_id: 8b3d645a-96c0-407e-871d-6f4a0b69557b
|
||||||
to_id: 7e3ae680-3d7e-4ae9-b82f-5bfbe1c2f613
|
# to_id: 7e3ae680-3d7e-4ae9-b82f-5bfbe1c2f613
|
||||||
from_port: 0
|
# from_port: 0
|
||||||
to_port: 0
|
# to_port: 0
|
||||||
- from_id: ba32e05c-0c80-4a79-b5ce-5b8150400e05
|
# - from_id: ba32e05c-0c80-4a79-b5ce-5b8150400e05
|
||||||
to_id: 7e3ae680-3d7e-4ae9-b82f-5bfbe1c2f613
|
# to_id: 7e3ae680-3d7e-4ae9-b82f-5bfbe1c2f613
|
||||||
from_port: 0
|
# from_port: 0
|
||||||
to_port: 0
|
# to_port: 0
|
||||||
room_node_data_list:
|
room_node_data_list:
|
||||||
- id: c0255eb6-2c75-44f7-9058-0921fe8fb0d8
|
- id: c0255eb6-2c75-44f7-9058-0921fe8fb0d8
|
||||||
title: 起点房间
|
title: 起点房间
|
||||||
|
|
|
@ -15,82 +15,82 @@ namespace ColdMint.scripts.loader.sceneLoader;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class GameSceneLoader : SceneLoaderTemplate
|
public partial class GameSceneLoader : SceneLoaderTemplate
|
||||||
{
|
{
|
||||||
private Label? _seedLabel;
|
private Label? _seedLabel;
|
||||||
|
|
||||||
public override Task InitializeData()
|
public override Task InitializeData()
|
||||||
{
|
{
|
||||||
//Loading the blood bar scene
|
//Loading the blood bar scene
|
||||||
//加载血条场景
|
//加载血条场景
|
||||||
var healthBarUi = GetNode<HealthBarUi>("CanvasLayer/Control/VBoxContainer/HealthBarUi");
|
var healthBarUi = GetNode<HealthBarUi>("CanvasLayer/Control/VBoxContainer/HealthBarUi");
|
||||||
GameSceneNodeHolder.HealthBarUi = healthBarUi;
|
GameSceneNodeHolder.HealthBarUi = healthBarUi;
|
||||||
//Load HotBar
|
//Load HotBar
|
||||||
//加载HotBar
|
//加载HotBar
|
||||||
var hotBar = GetNode<HotBar>("CanvasLayer/Control/VBoxContainer/HotBar");
|
var hotBar = GetNode<HotBar>("CanvasLayer/Control/VBoxContainer/HotBar");
|
||||||
GameSceneNodeHolder.HotBar = hotBar;
|
GameSceneNodeHolder.HotBar = hotBar;
|
||||||
//Backpack Ui container
|
//Backpack Ui container
|
||||||
//背包Ui容器
|
//背包Ui容器
|
||||||
var backpackUiContainer = GetNode<Control>("CanvasLayer/BackpackUIContainer");
|
var backpackUiContainer = GetNode<Control>("CanvasLayer/BackpackUIContainer");
|
||||||
GameSceneNodeHolder.BackpackUiContainer = backpackUiContainer;
|
GameSceneNodeHolder.BackpackUiContainer = backpackUiContainer;
|
||||||
//Load operation prompt
|
//Load operation prompt
|
||||||
//加载操作提示
|
//加载操作提示
|
||||||
var operationTip = GetNode<RichTextLabel>("CanvasLayer/Control/VBoxContainer/OperationTip");
|
var operationTip = GetNode<RichTextLabel>("CanvasLayer/Control/VBoxContainer/OperationTip");
|
||||||
GameSceneNodeHolder.OperationTipLabel = operationTip;
|
GameSceneNodeHolder.OperationTipLabel = operationTip;
|
||||||
//Loaded weapon container
|
//Loaded weapon container
|
||||||
//加载武器容器
|
//加载武器容器
|
||||||
var weaponContainer = GetNode<Node2D>("WeaponContainer");
|
var weaponContainer = GetNode<Node2D>("WeaponContainer");
|
||||||
GameSceneNodeHolder.WeaponContainer = weaponContainer;
|
GameSceneNodeHolder.WeaponContainer = weaponContainer;
|
||||||
//Load Packsack container
|
//Load Packsack container
|
||||||
//加载背包容器
|
//加载背包容器
|
||||||
var packsackContainer = GetNode<Node2D>("PacksackContainer");
|
var packsackContainer = GetNode<Node2D>("PacksackContainer");
|
||||||
GameSceneNodeHolder.PacksackContainer = packsackContainer;
|
GameSceneNodeHolder.PacksackContainer = packsackContainer;
|
||||||
//Load AICharacter container
|
//Load AICharacter container
|
||||||
//加载AICharacter容器
|
//加载AICharacter容器
|
||||||
var aiCharacterContainer = GetNode<Node2D>("AICharacterContainer");
|
var aiCharacterContainer = GetNode<Node2D>("AICharacterContainer");
|
||||||
GameSceneNodeHolder.AiCharacterContainer = aiCharacterContainer;
|
GameSceneNodeHolder.AiCharacterContainer = aiCharacterContainer;
|
||||||
//Load player container
|
//Load player container
|
||||||
//加载玩家容器
|
//加载玩家容器
|
||||||
var playerContainer = GetNode<Node2D>("PlayerContainer");
|
var playerContainer = GetNode<Node2D>("PlayerContainer");
|
||||||
GameSceneNodeHolder.PlayerContainer = playerContainer;
|
GameSceneNodeHolder.PlayerContainer = playerContainer;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task LoadScene()
|
public override async Task LoadScene()
|
||||||
{
|
{
|
||||||
var debugMode = Config.IsDebug();
|
var debugMode = Config.IsDebug();
|
||||||
var recreateMapButton = GetNodeOrNull<Button>("CanvasLayer/Control/RecreateMapButton");
|
var recreateMapButton = GetNodeOrNull<Button>("CanvasLayer/Control/RecreateMapButton");
|
||||||
if (recreateMapButton != null)
|
if (recreateMapButton != null)
|
||||||
{
|
{
|
||||||
recreateMapButton.Visible = debugMode;
|
recreateMapButton.Visible = debugMode;
|
||||||
recreateMapButton.Pressed += () => { _ = GenerateMap(); };
|
recreateMapButton.Pressed += () => { _ = GenerateMap(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
_seedLabel = GetNodeOrNull<Label>("CanvasLayer/Control/SeedLabel");
|
_seedLabel = GetNodeOrNull<Label>("CanvasLayer/Control/SeedLabel");
|
||||||
if (_seedLabel != null)
|
if (_seedLabel != null)
|
||||||
{
|
{
|
||||||
_seedLabel.Visible = debugMode;
|
_seedLabel.Visible = debugMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapGenerator.MapRoot = GetNode<Node>("MapRoot");
|
MapGenerator.MapRoot = GetNode<Node>("MapRoot");
|
||||||
MapGenerator.LayoutStrategy = new TestLayoutStrategy();
|
MapGenerator.LayoutStrategy = new TestLayoutStrategy();
|
||||||
MapGenerator.LayoutParsingStrategy = new SequenceLayoutParsingStrategy();
|
MapGenerator.LayoutParsingStrategy = new SequenceLayoutParsingStrategy();
|
||||||
MapGenerator.RoomPlacementStrategy = new PatchworkRoomPlacementStrategy();
|
MapGenerator.RoomPlacementStrategy = new PatchworkRoomPlacementStrategy();
|
||||||
await GenerateMap();
|
await GenerateMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Generate map</para>
|
/// <para>Generate map</para>
|
||||||
/// <para>生成地图</para>
|
/// <para>生成地图</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task GenerateMap()
|
private async Task GenerateMap()
|
||||||
{
|
{
|
||||||
MapGenerator.Seed = GuidUtils.GetGuid();
|
MapGenerator.Seed = GuidUtils.GetGuid();
|
||||||
if (_seedLabel != null)
|
if (_seedLabel != null)
|
||||||
{
|
{
|
||||||
//If you have a seedLabel, then set the seed to it.
|
//If you have a seedLabel, then set the seed to it.
|
||||||
//如果有seedLabel,那么将种子设置上去。
|
//如果有seedLabel,那么将种子设置上去。
|
||||||
var seedInfo = TranslationServerUtils.TranslateWithFormat("ui_seed_info", MapGenerator.Seed);
|
var seedInfo = TranslationServerUtils.TranslateWithFormat("ui_seed_info", MapGenerator.Seed);
|
||||||
_seedLabel.Text = seedInfo ?? $"Seed: {MapGenerator.Seed}";
|
_seedLabel.Text = seedInfo ?? $"Seed: {MapGenerator.Seed}";
|
||||||
}
|
}
|
||||||
await MapGenerator.GenerateMap();
|
await MapGenerator.GenerateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,100 +20,100 @@ namespace ColdMint.scripts.loader.uiLoader;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SplashScreenLoader : UiLoaderTemplate
|
public partial class SplashScreenLoader : UiLoaderTemplate
|
||||||
{
|
{
|
||||||
private Label? _loadingLabel;
|
private Label? _loadingLabel;
|
||||||
private PackedScene? _mainMenuScene;
|
private PackedScene? _mainMenuScene;
|
||||||
private AnimationPlayer? _animationPlayer;
|
private AnimationPlayer? _animationPlayer;
|
||||||
private string _startup = "startup";
|
private string _startup = "startup";
|
||||||
private Label? _nameLabel;
|
private Label? _nameLabel;
|
||||||
|
|
||||||
public override void InitializeData()
|
public override void InitializeData()
|
||||||
{
|
{
|
||||||
_mainMenuScene = GD.Load<PackedScene>("res://scenes/mainMenu.tscn");
|
_mainMenuScene = GD.Load<PackedScene>("res://scenes/mainMenu.tscn");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void InitializeUi()
|
public override void InitializeUi()
|
||||||
{
|
{
|
||||||
_nameLabel = GetNode<Label>("NameLabel");
|
_nameLabel = GetNode<Label>("NameLabel");
|
||||||
_loadingLabel = GetNode<Label>("loadingStateLabel");
|
_loadingLabel = GetNode<Label>("loadingStateLabel");
|
||||||
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||||
//Disable animation in Debug mode.
|
//Disable animation in Debug mode.
|
||||||
//在Debug模式禁用动画。
|
//在Debug模式禁用动画。
|
||||||
if (Config.IsDebug())
|
if (Config.IsDebug())
|
||||||
{
|
{
|
||||||
_loadingLabel.Modulate = Colors.White;
|
_loadingLabel.Modulate = Colors.White;
|
||||||
_nameLabel.Modulate = Colors.White;
|
_nameLabel.Modulate = Colors.White;
|
||||||
AnimationFinished(_startup);
|
AnimationFinished(_startup);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_animationPlayer.Play(_startup);
|
_animationPlayer.Play(_startup);
|
||||||
_animationPlayer.AnimationFinished += AnimationFinished;
|
_animationPlayer.AnimationFinished += AnimationFinished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void AnimationFinished(StringName name)
|
private async void AnimationFinished(StringName name)
|
||||||
{
|
{
|
||||||
await LoadingGlobalData();
|
await LoadingGlobalData();
|
||||||
if (_mainMenuScene == null)
|
if (_mainMenuScene == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(_mainMenuScene);
|
GetTree().ChangeSceneToPacked(_mainMenuScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Load the game's global data</para>
|
/// <para>Load the game's global data</para>
|
||||||
/// <para>加载游戏的全局数据</para>
|
/// <para>加载游戏的全局数据</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task LoadingGlobalData()
|
private async Task LoadingGlobalData()
|
||||||
{
|
{
|
||||||
//Loading App configuration
|
//Loading App configuration
|
||||||
//加载App配置
|
//加载App配置
|
||||||
var appConfigData = AppConfig.LoadFromFile();
|
var appConfigData = AppConfig.LoadFromFile();
|
||||||
if (appConfigData != null)
|
if (appConfigData != null)
|
||||||
{
|
{
|
||||||
AppConfig.ApplyAppConfig(appConfigData);
|
AppConfig.ApplyAppConfig(appConfigData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set the minimum log level to Info in debug mode.(Print all logs)
|
//Set the minimum log level to Info in debug mode.(Print all logs)
|
||||||
//在调试模式下将最小日志等级设置为Info。(打印全部日志)
|
//在调试模式下将最小日志等级设置为Info。(打印全部日志)
|
||||||
//Disable all logs in the release version.
|
//Disable all logs in the release version.
|
||||||
//在发行版禁用所有日志。
|
//在发行版禁用所有日志。
|
||||||
LogCat.MinLogLevel = Config.IsDebug() ? LogCat.InfoLogLevel : LogCat.DisableAllLogLevel;
|
LogCat.MinLogLevel = Config.IsDebug() ? LogCat.InfoLogLevel : LogCat.DisableAllLogLevel;
|
||||||
ContributorDataManager.RegisterAllContributorData();
|
ContributorDataManager.RegisterAllContributorData();
|
||||||
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
||||||
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
||||||
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
||||||
//Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package
|
//Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package
|
||||||
//注册对应的编码提供程序,解决压缩包中文路径乱码问题
|
//注册对应的编码提供程序,解决压缩包中文路径乱码问题
|
||||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
//创建游戏数据文件夹
|
//创建游戏数据文件夹
|
||||||
var dataPath = Config.GetGameDataDirectory();
|
var dataPath = Config.GetGameDataDirectory();
|
||||||
if (!Directory.Exists(dataPath))
|
if (!Directory.Exists(dataPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dataPath);
|
Directory.CreateDirectory(dataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Registered camp
|
//Registered camp
|
||||||
//注册阵营
|
//注册阵营
|
||||||
var defaultCamp = new Camp(Config.CampId.Default)
|
var defaultCamp = new Camp(Config.CampId.Default)
|
||||||
{
|
{
|
||||||
FriendInjury = true
|
FriendInjury = true
|
||||||
};
|
};
|
||||||
CampManager.SetDefaultCamp(defaultCamp);
|
CampManager.SetDefaultCamp(defaultCamp);
|
||||||
var mazoku = new Camp(Config.CampId.Mazoku);
|
var mazoku = new Camp(Config.CampId.Mazoku);
|
||||||
CampManager.AddCamp(mazoku);
|
CampManager.AddCamp(mazoku);
|
||||||
var aborigines = new Camp(Config.CampId.Aborigines);
|
var aborigines = new Camp(Config.CampId.Aborigines);
|
||||||
CampManager.AddCamp(aborigines);
|
CampManager.AddCamp(aborigines);
|
||||||
//Register ItemTypes from file
|
//Register ItemTypes from file
|
||||||
//从文件注册物品类型
|
//从文件注册物品类型
|
||||||
ItemTypeRegister.RegisterFromFile();
|
ItemTypeRegister.RegisterFromFile();
|
||||||
//Hardcoded ItemTypes Register
|
//Hardcoded ItemTypes Register
|
||||||
//硬编码注册物品类型
|
//硬编码注册物品类型
|
||||||
ItemTypeRegister.StaticRegister();
|
ItemTypeRegister.StaticRegister();
|
||||||
//静态注册掉落表
|
//静态注册掉落表
|
||||||
LootRegister.StaticRegister();
|
LootRegister.StaticRegister();
|
||||||
await Task.Delay(TimeSpan.FromMilliseconds(500));
|
await Task.Delay(TimeSpan.FromMilliseconds(500));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,12 +14,19 @@ public class RoomPlacementData
|
||||||
/// <para>放置的位置</para>
|
/// <para>放置的位置</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2? Position { get; set; }
|
public Vector2? Position { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Place the room template</para>
|
/// <para>Place the room template</para>
|
||||||
/// <para>放置的房间模板</para>
|
/// <para>放置的房间模板</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Room? Room { get; set; }
|
public Room? Room { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Parent room</para>
|
||||||
|
/// <para>父级房间</para>
|
||||||
|
/// </summary>
|
||||||
|
public Room? ParentRoom { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Parent room slot</para>
|
/// <para>Parent room slot</para>
|
||||||
/// <para>父级房间的插槽</para>
|
/// <para>父级房间的插槽</para>
|
||||||
|
|
|
@ -16,8 +16,34 @@ public class RoomSlot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Matched { get; set; }
|
public bool Matched { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>The starting position of the room slot</para>
|
||||||
|
/// <para>房间插槽的开始位置</para>
|
||||||
|
/// </summary>
|
||||||
|
///<remarks>
|
||||||
|
///<para>As opposed to a tile map. Convert to local location please call <see cref="TileMap.MapToLocal"/></para>
|
||||||
|
///<para>相对于瓦片地图而言的。转换为本地位置请调用<see cref="TileMap.MapToLocal"/></para>
|
||||||
|
/// </remarks>
|
||||||
public Vector2I StartPosition { get; set; }
|
public Vector2I StartPosition { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>The midpoint of the slot</para>
|
||||||
|
/// <para>插槽的中点位置</para>
|
||||||
|
/// </summary>
|
||||||
|
///<remarks>
|
||||||
|
///<para>As opposed to a tile map. Convert to local location please call <see cref="TileMap.MapToLocal"/></para>
|
||||||
|
///<para>相对于瓦片地图而言的。转换为本地位置请调用<see cref="TileMap.MapToLocal"/></para>
|
||||||
|
/// </remarks>
|
||||||
|
public Vector2I MidpointPosition { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>The end position of the room slot</para>
|
||||||
|
/// <para>房间插槽的结束位置</para>
|
||||||
|
/// </summary>
|
||||||
|
///<remarks>
|
||||||
|
///<para>As opposed to a tile map. Convert to local location please call <see cref="TileMap.MapToLocal"/></para>
|
||||||
|
///<para>相对于瓦片地图而言的。转换为本地位置请调用<see cref="TileMap.MapToLocal"/></para>
|
||||||
|
/// </remarks>
|
||||||
public Vector2I EndPosition { get; set; }
|
public Vector2I EndPosition { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -194,10 +194,12 @@ public class Room
|
||||||
//转为瓦片地图的坐标(中点)
|
//转为瓦片地图的坐标(中点)
|
||||||
var tileMapStartPosition = tileMap.LocalToMap(startPosition);
|
var tileMapStartPosition = tileMap.LocalToMap(startPosition);
|
||||||
var tileMapEndPosition = tileMap.LocalToMap(endPosition);
|
var tileMapEndPosition = tileMap.LocalToMap(endPosition);
|
||||||
|
var midpointPosition = tileMap.LocalToMap(midpointOfRoomSlots);
|
||||||
var roomSlot = new RoomSlot
|
var roomSlot = new RoomSlot
|
||||||
{
|
{
|
||||||
EndPosition = tileMapEndPosition,
|
EndPosition = tileMapEndPosition,
|
||||||
StartPosition = tileMapStartPosition,
|
StartPosition = tileMapStartPosition,
|
||||||
|
MidpointPosition = midpointPosition,
|
||||||
//Calculate the orientation of the slot (the midpoint of the room is the origin, the vector pointing to the midpoint of the slot)
|
//Calculate the orientation of the slot (the midpoint of the room is the origin, the vector pointing to the midpoint of the slot)
|
||||||
//计算槽位的方向(房间中点为原点,指向槽位中点的向量)
|
//计算槽位的方向(房间中点为原点,指向槽位中点的向量)
|
||||||
DistanceToMidpointOfRoom = CoordinateUtils.VectorToOrientationArray(midpoint, midpointOfRoomSlots)
|
DistanceToMidpointOfRoom = CoordinateUtils.VectorToOrientationArray(midpoint, midpointOfRoomSlots)
|
||||||
|
|
|
@ -111,6 +111,27 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
|
||||||
var rootNode = roomPlacementData.Room.RootNode;
|
var rootNode = roomPlacementData.Room.RootNode;
|
||||||
mapRoot.AddChild(rootNode);
|
mapRoot.AddChild(rootNode);
|
||||||
rootNode.Position = roomPlacementData.Position.Value;
|
rootNode.Position = roomPlacementData.Position.Value;
|
||||||
|
//Place navigation Link
|
||||||
|
//放置导航Link
|
||||||
|
//计算旧房间插槽的绝对位置。
|
||||||
|
if (roomPlacementData.Room != null && roomPlacementData.ParentRoom != null )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// if (roomPlacementData.NewRoomSlot != null && roomPlacementData.ParentRoomSlot != null &&
|
||||||
|
// roomPlacementData.Position != null)
|
||||||
|
// {
|
||||||
|
// var navigationLink2D = new NavigationLink2D();
|
||||||
|
// navigationLink2D.Position = roomPlacementData.Position.Value;
|
||||||
|
// var startPosition = roomPlacementData.ParentRoomSlot.StartPosition;
|
||||||
|
// var actualStart = startPosition + roomPlacementData.Position.Value;
|
||||||
|
// navigationLink2D.StartPosition = actualStart;
|
||||||
|
// navigationLink2D.EndPosition = roomPlacementData.NewRoomSlot.StartPosition;
|
||||||
|
// mapRoot.AddChild(navigationLink2D);
|
||||||
|
// }
|
||||||
|
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +163,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
|
||||||
|
|
||||||
//Saves all data in the room template that matches the parent room.
|
//Saves all data in the room template that matches the parent room.
|
||||||
//保存房间模板内所有与父房间匹配的数据。
|
//保存房间模板内所有与父房间匹配的数据。
|
||||||
var useableRoomPlacementData = new List<RoomPlacementData>();
|
var usableRoomPlacementData = new List<RoomPlacementData>();
|
||||||
foreach (var roomRes in roomResArray)
|
foreach (var roomRes in roomResArray)
|
||||||
{
|
{
|
||||||
var newRoom = RoomFactory.CreateRoom(roomRes, newRoomNodeData.EnterRoomEventHandlerId,
|
var newRoom = RoomFactory.CreateRoom(roomRes, newRoomNodeData.EnterRoomEventHandlerId,
|
||||||
|
@ -169,21 +190,22 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
|
||||||
var roomPlacementData = new RoomPlacementData
|
var roomPlacementData = new RoomPlacementData
|
||||||
{
|
{
|
||||||
Room = newRoom,
|
Room = newRoom,
|
||||||
|
ParentRoom = parentRoomNode,
|
||||||
Position = position,
|
Position = position,
|
||||||
ParentRoomSlot = mainRoomSlot,
|
ParentRoomSlot = mainRoomSlot,
|
||||||
NewRoomSlot = newRoomSlot
|
NewRoomSlot = newRoomSlot
|
||||||
};
|
};
|
||||||
useableRoomPlacementData.Add(roomPlacementData);
|
usableRoomPlacementData.Add(roomPlacementData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useableRoomPlacementData.Count == 0)
|
if (usableRoomPlacementData.Count == 0)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var index = randomNumberGenerator.Randi() % useableRoomPlacementData.Count;
|
var index = randomNumberGenerator.Randi() % usableRoomPlacementData.Count;
|
||||||
var roomPlacementData = useableRoomPlacementData[(int)index];
|
var roomPlacementData = usableRoomPlacementData[(int)index];
|
||||||
//Be sure to mark its slot as a match when you use it.
|
//Be sure to mark its slot as a match when you use it.
|
||||||
//一定要在使用时,将其插槽标记为匹配。
|
//一定要在使用时,将其插槽标记为匹配。
|
||||||
if (roomPlacementData.ParentRoomSlot != null)
|
if (roomPlacementData.ParentRoomSlot != null)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user