连接导航网格中。
This commit is contained in:
parent
9401913779
commit
b0c01cfca0
|
@ -3,22 +3,22 @@ connection_data_list:
|
|||
to_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
||||
from_port: 0
|
||||
to_port: 0
|
||||
- from_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
||||
to_id: ba32e05c-0c80-4a79-b5ce-5b8150400e05
|
||||
from_port: 0
|
||||
to_port: 0
|
||||
- from_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
||||
to_id: 8b3d645a-96c0-407e-871d-6f4a0b69557b
|
||||
from_port: 0
|
||||
to_port: 0
|
||||
- from_id: 8b3d645a-96c0-407e-871d-6f4a0b69557b
|
||||
to_id: 7e3ae680-3d7e-4ae9-b82f-5bfbe1c2f613
|
||||
from_port: 0
|
||||
to_port: 0
|
||||
- from_id: ba32e05c-0c80-4a79-b5ce-5b8150400e05
|
||||
to_id: 7e3ae680-3d7e-4ae9-b82f-5bfbe1c2f613
|
||||
from_port: 0
|
||||
to_port: 0
|
||||
# - from_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
||||
# to_id: ba32e05c-0c80-4a79-b5ce-5b8150400e05
|
||||
# from_port: 0
|
||||
# to_port: 0
|
||||
# - from_id: 4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03
|
||||
# to_id: 8b3d645a-96c0-407e-871d-6f4a0b69557b
|
||||
# from_port: 0
|
||||
# to_port: 0
|
||||
# - from_id: 8b3d645a-96c0-407e-871d-6f4a0b69557b
|
||||
# to_id: 7e3ae680-3d7e-4ae9-b82f-5bfbe1c2f613
|
||||
# from_port: 0
|
||||
# to_port: 0
|
||||
# - from_id: ba32e05c-0c80-4a79-b5ce-5b8150400e05
|
||||
# to_id: 7e3ae680-3d7e-4ae9-b82f-5bfbe1c2f613
|
||||
# from_port: 0
|
||||
# to_port: 0
|
||||
room_node_data_list:
|
||||
- id: c0255eb6-2c75-44f7-9058-0921fe8fb0d8
|
||||
title: 起点房间
|
||||
|
|
|
@ -14,12 +14,19 @@ public class RoomPlacementData
|
|||
/// <para>放置的位置</para>
|
||||
/// </summary>
|
||||
public Vector2? Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Place the room template</para>
|
||||
/// <para>放置的房间模板</para>
|
||||
/// </summary>
|
||||
public Room? Room { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Parent room</para>
|
||||
/// <para>父级房间</para>
|
||||
/// </summary>
|
||||
public Room? ParentRoom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Parent room slot</para>
|
||||
/// <para>父级房间的插槽</para>
|
||||
|
|
|
@ -16,8 +16,34 @@ public class RoomSlot
|
|||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <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; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -194,10 +194,12 @@ public class Room
|
|||
//转为瓦片地图的坐标(中点)
|
||||
var tileMapStartPosition = tileMap.LocalToMap(startPosition);
|
||||
var tileMapEndPosition = tileMap.LocalToMap(endPosition);
|
||||
var midpointPosition = tileMap.LocalToMap(midpointOfRoomSlots);
|
||||
var roomSlot = new RoomSlot
|
||||
{
|
||||
EndPosition = tileMapEndPosition,
|
||||
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)
|
||||
//计算槽位的方向(房间中点为原点,指向槽位中点的向量)
|
||||
DistanceToMidpointOfRoom = CoordinateUtils.VectorToOrientationArray(midpoint, midpointOfRoomSlots)
|
||||
|
|
|
@ -111,6 +111,27 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
|
|||
var rootNode = roomPlacementData.Room.RootNode;
|
||||
mapRoot.AddChild(rootNode);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -142,7 +163,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
|
|||
|
||||
//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)
|
||||
{
|
||||
var newRoom = RoomFactory.CreateRoom(roomRes, newRoomNodeData.EnterRoomEventHandlerId,
|
||||
|
@ -169,21 +190,22 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
|
|||
var roomPlacementData = new RoomPlacementData
|
||||
{
|
||||
Room = newRoom,
|
||||
ParentRoom = parentRoomNode,
|
||||
Position = position,
|
||||
ParentRoomSlot = mainRoomSlot,
|
||||
NewRoomSlot = newRoomSlot
|
||||
};
|
||||
useableRoomPlacementData.Add(roomPlacementData);
|
||||
usableRoomPlacementData.Add(roomPlacementData);
|
||||
}
|
||||
|
||||
if (useableRoomPlacementData.Count == 0)
|
||||
if (usableRoomPlacementData.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = randomNumberGenerator.Randi() % useableRoomPlacementData.Count;
|
||||
var roomPlacementData = useableRoomPlacementData[(int)index];
|
||||
var index = randomNumberGenerator.Randi() % usableRoomPlacementData.Count;
|
||||
var roomPlacementData = usableRoomPlacementData[(int)index];
|
||||
//Be sure to mark its slot as a match when you use it.
|
||||
//一定要在使用时,将其插槽标记为匹配。
|
||||
if (roomPlacementData.ParentRoomSlot != null)
|
||||
|
|
Loading…
Reference in New Issue
Block a user