diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/inlet/Start1/RoomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/inlet/Start1/RoomInfo.json index e5b6e24..d224396 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/inlet/Start1/RoomInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/inlet/Start1/RoomInfo.json @@ -1 +1 @@ -{"Position":{"X":-3,"Y":-6},"Size":{"X":14,"Y":13},"DoorAreaInfos":[],"GroupName":"TestGroup2","RoomType":1,"RoomName":"Start1","Weight":100,"Remark":""} \ No newline at end of file +{"Position":{"X":-3,"Y":-6},"Size":{"X":14,"Y":13},"DoorAreaInfos":[{"Direction":0,"Start":16,"End":128},{"Direction":1,"Start":32,"End":128},{"Direction":3,"Start":0,"End":128},{"Direction":2,"Start":16,"End":144}],"GroupName":"TestGroup2","RoomType":1,"RoomName":"Start1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/scene/World.tscn b/DungeonShooting_Godot/scene/World.tscn index eccc7be..6b6ae51 100644 --- a/DungeonShooting_Godot/scene/World.tscn +++ b/DungeonShooting_Godot/scene/World.tscn @@ -29,7 +29,7 @@ layer_1/name = "Middle" layer_1/tile_data = PackedInt32Array() layer_2/name = "Top" -layer_2/modulate = Color(1, 1, 1, 0.196078) +layer_2/modulate = Color(1, 1, 1, 0.784314) layer_2/z_index = 10 layer_2/tile_data = PackedInt32Array() layer_3/name = "AisleFloor" diff --git a/DungeonShooting_Godot/src/framework/map/DungeonConfig.cs b/DungeonShooting_Godot/src/framework/map/DungeonConfig.cs index f546877..b966846 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonConfig.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonConfig.cs @@ -14,7 +14,7 @@ /// /// 房间数量 /// - public int RoomCount = 3; + public int RoomCount = 5; /// /// 是否指定了房间 diff --git a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs index 6094e54..6d725a8 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs @@ -51,13 +51,13 @@ //房间横轴分散程度 private float _roomHorizontalMinDispersion = 0f; - private float _roomHorizontalMaxDispersion = 2.5f; + private float _roomHorizontalMaxDispersion = 0.5f; // private float _roomHorizontalMinDispersion = 0f; // private float _roomHorizontalMaxDispersion = 2f; //房间纵轴分散程度 private float _roomVerticalMinDispersion = 0f; - private float _roomVerticalMaxDispersion = 2.5f; + private float _roomVerticalMaxDispersion = 0.5f; // private float _roomVerticalMinDispersion = 0f; // private float _roomVerticalMaxDispersion = 2f; diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs index 43e8f10..9701494 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs @@ -58,20 +58,20 @@ roomInfo.Size - new Vector2(2, 2)); FillRect(GameConfig.TopMapLayer, config.IN_LT, roomInfo.Position, Vector2.One); - FillRect(GameConfig.TopMapLayer, config.L, roomInfo.Position + new Vector2(0, 1), + FillRect(GameConfig.TopMapLayer, config.Wall_Left, roomInfo.Position + new Vector2(0, 1), new Vector2(1, roomInfo.Size.Y - 2)); FillRect(GameConfig.TopMapLayer, config.IN_LB, roomInfo.Position + new Vector2(0, roomInfo.Size.Y - 1), new Vector2(1, 1)); - FillRect(GameConfig.TopMapLayer, config.B, roomInfo.Position + new Vector2(1, roomInfo.Size.Y - 1), + FillRect(GameConfig.TopMapLayer, config.Wall_Bottom, roomInfo.Position + new Vector2(1, roomInfo.Size.Y - 1), new Vector2(roomInfo.Size.X - 2, 1)); FillRect(GameConfig.TopMapLayer, config.IN_RB, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, roomInfo.Size.Y - 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.R, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, 1), + FillRect(GameConfig.TopMapLayer, config.Wall_Right, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, 1), new Vector2(1, roomInfo.Size.Y - 2)); FillRect(GameConfig.TopMapLayer, config.IN_RT, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, 0), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.T, roomInfo.Position + Vector2.Right, + FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, roomInfo.Position + Vector2.Right, new Vector2(roomInfo.Size.X - 2, 1)); } else @@ -294,50 +294,50 @@ if ((doorDir1 == DoorDirection.N && doorDir2 == DoorDirection.E) || //↑→ (doorDir2 == DoorDirection.N && doorDir1 == DoorDirection.E)) { - FillRect(GameConfig.TopMapLayer, config.OUT_RT, + FillRect(GameConfig.TopMapLayer, config.Wall_Out_RT, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), Vector2.One); FillRect(GameConfig.TopMapLayer, config.IN_RT, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 0), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.T, doorInfo.Cross, new Vector2(GameConfig.CorridorWidth - 1, 1)); - FillRect(GameConfig.TopMapLayer, config.R, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 1), + FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, doorInfo.Cross, new Vector2(GameConfig.CorridorWidth - 1, 1)); + FillRect(GameConfig.TopMapLayer, config.Wall_Right, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 1), new Vector2(1, GameConfig.CorridorWidth - 1)); } else if ((doorDir1 == DoorDirection.E && doorDir2 == DoorDirection.S) || //→↓ (doorDir2 == DoorDirection.E && doorDir1 == DoorDirection.S)) { - FillRect(GameConfig.MiddleMapLayer, config.OUT_RB, doorInfo.Cross, Vector2.One); + FillRect(GameConfig.MiddleMapLayer, config.Wall_Out_RB, doorInfo.Cross, Vector2.One); FillRect(GameConfig.TopMapLayer, config.IN_RB, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, GameConfig.CorridorWidth - 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.R, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 0), + FillRect(GameConfig.TopMapLayer, config.Wall_Right, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 0), new Vector2(1, GameConfig.CorridorWidth - 1)); - FillRect(GameConfig.TopMapLayer, config.B, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), + FillRect(GameConfig.TopMapLayer, config.Wall_Bottom, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), new Vector2(GameConfig.CorridorWidth - 1, 1)); } else if ((doorDir1 == DoorDirection.S && doorDir2 == DoorDirection.W) || //↓← (doorDir2 == DoorDirection.S && doorDir1 == DoorDirection.W)) { - FillRect(GameConfig.MiddleMapLayer, config.OUT_LB, + FillRect(GameConfig.MiddleMapLayer, config.Wall_Out_LB, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 0), Vector2.One); FillRect(GameConfig.TopMapLayer, config.IN_LB, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.L, doorInfo.Cross, new Vector2(1, GameConfig.CorridorWidth - 1)); - FillRect(GameConfig.TopMapLayer, config.B, doorInfo.Cross + new Vector2(1, GameConfig.CorridorWidth - 1), + FillRect(GameConfig.TopMapLayer, config.Wall_Left, doorInfo.Cross, new Vector2(1, GameConfig.CorridorWidth - 1)); + FillRect(GameConfig.TopMapLayer, config.Wall_Bottom, doorInfo.Cross + new Vector2(1, GameConfig.CorridorWidth - 1), new Vector2(GameConfig.CorridorWidth - 1, 1)); } else if ((doorDir1 == DoorDirection.W && doorDir2 == DoorDirection.N) || //←↑ (doorDir2 == DoorDirection.W && doorDir1 == DoorDirection.N)) { - FillRect(GameConfig.TopMapLayer, config.OUT_LT, + FillRect(GameConfig.TopMapLayer, config.Wall_Out_LT, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, GameConfig.CorridorWidth - 1), Vector2.One); FillRect(GameConfig.TopMapLayer, config.IN_LT, doorInfo.Cross, Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.T, doorInfo.Cross + new Vector2(1, 0), + FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, doorInfo.Cross + new Vector2(1, 0), new Vector2(GameConfig.CorridorWidth - 1, 1)); - FillRect(GameConfig.TopMapLayer, config.L, doorInfo.Cross + new Vector2(0, 1), + FillRect(GameConfig.TopMapLayer, config.Wall_Left, doorInfo.Cross + new Vector2(0, 1), new Vector2(1, GameConfig.CorridorWidth - 1)); } @@ -530,16 +530,21 @@ private void FullHorizontalAisle(AutoTileConfig config, Rect2 rect) { FillRect(GameConfig.AisleFloorMapLayer, config.Floor, rect.Position + new Vector2(0, 1), rect.Size - new Vector2(0, 2)); - FillRect(GameConfig.MiddleMapLayer, config.T, rect.Position, new Vector2(rect.Size.X, 1)); - FillRect(GameConfig.TopMapLayer, config.B, rect.Position + new Vector2(0, rect.Size.Y - 1), new Vector2(rect.Size.X, 1)); + FillRect(GameConfig.TopMapLayer, config.TopMask, rect.Position - new Vector2(0, 2), new Vector2(rect.Size.X, 1)); + FillRect(GameConfig.TopMapLayer, config.TopMask, rect.Position + new Vector2(0, rect.Size.Y), new Vector2(rect.Size.X, 1)); + FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, rect.Position - new Vector2(0, 1), new Vector2(rect.Size.X, 1)); + FillRect(GameConfig.MiddleMapLayer, config.WallVertical_Center, rect.Position, new Vector2(rect.Size.X, 1)); + FillRect(GameConfig.TopMapLayer, config.Wall_Bottom, rect.Position + new Vector2(0, rect.Size.Y - 1), new Vector2(rect.Size.X, 1)); } //纵向过道 private void FullVerticalAisle(AutoTileConfig config, Rect2 rect) { FillRect(GameConfig.AisleFloorMapLayer, config.Floor, rect.Position + new Vector2(1, 0), rect.Size - new Vector2(2, 0)); - FillRect(GameConfig.TopMapLayer, config.L, rect.Position, new Vector2(1, rect.Size.Y)); - FillRect(GameConfig.TopMapLayer, config.R, rect.Position + new Vector2(rect.Size.X - 1, 0), new Vector2(1, rect.Size.Y)); + FillRect(GameConfig.TopMapLayer, config.TopMask, rect.Position - new Vector2(1, 0), new Vector2(1, rect.Size.Y - 1)); + FillRect(GameConfig.TopMapLayer, config.TopMask, rect.Position + new Vector2(rect.Size.X, 0), new Vector2(1, rect.Size.Y - 1)); + FillRect(GameConfig.TopMapLayer, config.Wall_Left, rect.Position, new Vector2(1, rect.Size.Y - 1)); + FillRect(GameConfig.TopMapLayer, config.Wall_Right, rect.Position + new Vector2(rect.Size.X - 1, 0), new Vector2(1, rect.Size.Y - 1)); } //横向过道, 门朝右, 连接方向向左 @@ -554,9 +559,21 @@ } else { - ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(-1, 0), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.OUT_LB, rect.Position + new Vector2(-1, 0), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.OUT_LT, rect.Position + new Vector2(-1, 3), Vector2.One); + var atlasCoords = _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, (rect.Position - new Vector2(1, 1)).AsVector2I()); + ClearRect(GameConfig.TopMapLayer, rect.Position - new Vector2(1, 1), new Vector2(2, 4)); + + if (atlasCoords == config.Wall_Right.AutoTileCoords) + { + FillRect(GameConfig.MiddleMapLayer, config.WallVertical_Left, rect.Position - new Vector2(1, 0), Vector2.One); + FillRect(GameConfig.TopMapLayer, config.Wall_Out_LB, rect.Position - new Vector2(1, 1), Vector2.One); + } + else + { + FillRect(GameConfig.MiddleMapLayer, config.WallVertical_Center, rect.Position - new Vector2(1, 0), Vector2.One); + FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, rect.Position - new Vector2(1, 1), Vector2.One); + } + + FillRect(GameConfig.TopMapLayer, config.Wall_Out_LT, rect.Position + new Vector2(-1, 3), Vector2.One); FillRect(GameConfig.FloorMapLayer, config.Floor, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.Y - 2)); //生成门的导航区域 @@ -588,9 +605,21 @@ } else { - ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(rect.Size.X, 0), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.OUT_RB, rect.Position + new Vector2(rect.Size.X, 0), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.OUT_RT, rect.Position + new Vector2(rect.Size.X, 3), Vector2.One); + var atlasCoords = _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, (rect.Position + new Vector2(rect.Size.X, -1)).AsVector2I()); + ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(rect.Size.X - 1, -1), new Vector2(2, 4)); + + if (atlasCoords == config.Wall_Left.AutoTileCoords) + { + FillRect(GameConfig.MiddleMapLayer, config.WallVertical_Right, rect.Position + new Vector2(rect.Size.X, 0), Vector2.One); + FillRect(GameConfig.TopMapLayer, config.Wall_Out_RB, rect.Position + new Vector2(rect.Size.X, -1), Vector2.One); + } + else + { + FillRect(GameConfig.MiddleMapLayer, config.WallVertical_Center, rect.Position + new Vector2(rect.Size.X, 0), Vector2.One); + FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, rect.Position + new Vector2(rect.Size.X, -1), Vector2.One); + } + + FillRect(GameConfig.TopMapLayer, config.Wall_Out_RT, rect.Position + new Vector2(rect.Size.X, 3), Vector2.One); FillRect(GameConfig.FloorMapLayer, config.Floor, rect.Position + new Vector2(rect.Size.X, 1), new Vector2(1, rect.Size.Y - 2)); //生成门的导航区域 @@ -623,10 +652,13 @@ } else { - FillRect(GameConfig.TopMapLayer, config.OUT_RT, rect.Position + new Vector2(0, -1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.OUT_LT, rect.Position + new Vector2(3, -1), Vector2.One); + FillRect(GameConfig.TopMapLayer, config.Wall_Out_RT, rect.Position + new Vector2(0, -1), Vector2.One); + FillRect(GameConfig.TopMapLayer, config.Wall_Out_LT, rect.Position + new Vector2(3, -1), Vector2.One); FillRect(GameConfig.FloorMapLayer, config.Floor, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.X - 2, 1)); + ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(1, rect.Size.Y - 2), new Vector2(2, 2)); + ClearRect(GameConfig.MiddleMapLayer, rect.Position + new Vector2(1, rect.Size.Y), new Vector2(2, 1)); + //生成门的导航区域 var x = rect.Position.X * GameConfig.TileCellSize; var y = rect.Position.Y * GameConfig.TileCellSize; @@ -656,10 +688,13 @@ } else { - FillRect(GameConfig.MiddleMapLayer, config.OUT_RB, rect.Position + new Vector2(0, rect.Size.Y), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.OUT_LB, rect.Position + new Vector2(3, rect.Size.Y), Vector2.One); + FillRect(GameConfig.TopMapLayer, config.Wall_Out_RB, rect.Position + new Vector2(0, rect.Size.Y - 1), Vector2.One); + FillRect(GameConfig.TopMapLayer, config.Wall_Out_LB, rect.Position + new Vector2(3, rect.Size.Y - 1), Vector2.One); + FillRect(GameConfig.MiddleMapLayer, config.WallVertical_Right, rect.Position + new Vector2(0, rect.Size.Y), Vector2.One); + FillRect(GameConfig.MiddleMapLayer, config.WallVertical_Left, rect.Position + new Vector2(3, rect.Size.Y), Vector2.One); FillRect(GameConfig.FloorMapLayer, config.Floor, rect.Position + new Vector2(1, rect.Size.Y), new Vector2(rect.Size.X - 2, 1)); + ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(1, 0), new Vector2(2, 2)); //生成门的导航区域 var x = rect.Position.X * GameConfig.TileCellSize; var y = rect.Position.Y * GameConfig.TileCellSize; diff --git a/DungeonShooting_Godot/src/framework/map/TileCellData.cs b/DungeonShooting_Godot/src/framework/map/TileCellData.cs index 156da53..f747622 100644 --- a/DungeonShooting_Godot/src/framework/map/TileCellData.cs +++ b/DungeonShooting_Godot/src/framework/map/TileCellData.cs @@ -11,6 +11,13 @@ SourceId = sourceId; AutoTileCoords = autoTileCoords; } + + public TileCellData(int sourceId, Vector2I autoTileCoords, uint terrainPeering) + { + SourceId = sourceId; + AutoTileCoords = autoTileCoords; + TerrainPeering = terrainPeering; + } /// /// 在TileSet中的图块id, 也就是sourceId @@ -21,4 +28,14 @@ /// 如果是图块集, 该属性就表示在图块集的位置 /// public Vector2I AutoTileCoords; + + /// + /// 地形掩码, 0 表示没有配置地形 + /// + public uint TerrainPeering; + + /// + /// 默认存放层级 + /// + public int DefaultLayer = GameConfig.FloorMapLayer; } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/tileSet/TerrainPeering.cs b/DungeonShooting_Godot/src/framework/map/tileSet/TerrainPeering.cs index c256e59..0019d3b 100644 --- a/DungeonShooting_Godot/src/framework/map/tileSet/TerrainPeering.cs +++ b/DungeonShooting_Godot/src/framework/map/tileSet/TerrainPeering.cs @@ -47,6 +47,9 @@ /// public const uint RightBottom = 0b100000000; + /// + /// 获取地形掩码值 + /// public static uint GetTerrainPeeringValue(this TileData tileData) { if (tileData.Terrain != -1 && tileData.TerrainSet != -1) diff --git a/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs b/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs index 686d9b5..d32cc5c 100644 --- a/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs +++ b/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs @@ -11,17 +11,6 @@ public TileCellData IN_LB = new TileCellData(0, new Vector2I(11, 2)); public TileCellData IN_RT = new TileCellData(0, new Vector2I(1, 3)); public TileCellData IN_RB = new TileCellData(0, new Vector2I(13, 2)); - public TileCellData R = new TileCellData(0, new Vector2I(1, 3)); - public TileCellData L = new TileCellData(0, new Vector2I(3, 3)); - public TileCellData T = new TileCellData(0, new Vector2I(2, 7)); - public TileCellData B = new TileCellData(0, new Vector2I(2, 2)); - - public TileCellData OUT_LT = new TileCellData(0, new Vector2I(1, 2)); - public TileCellData OUT_LB = new TileCellData(0, new Vector2I(1, 7)); - public TileCellData OUT_RT = new TileCellData(0, new Vector2I(3, 2)); - public TileCellData OUT_RB = new TileCellData(0, new Vector2I(3, 7)); - - public TileCellData WALL_BLOCK = new TileCellData(0, new Vector2I(2, 3)); private List _middleLayerAtlasCoords = new List() { @@ -45,30 +34,25 @@ new Vector2I(11, 2), new Vector2I(13, 2), }; - - public int GetLayer(Vector2I atlasCoords) - { - var layer = GameConfig.FloorMapLayer; - if (_middleLayerAtlasCoords.Contains(atlasCoords)) - { - layer = GameConfig.MiddleMapLayer; - } - else if (_topLayerAtlasCoords.Contains(atlasCoords)) - { - layer = GameConfig.TopMapLayer; - } - - return layer; - } //----------------------------------------------------------- public TileCellData Floor = new TileCellData(0, new Vector2I(0, 4)); - public TileCellData TopMask = new TileCellData(0, new Vector2I(9, 2)); - public TileCellData WallLeft = new TileCellData(0, new Vector2I(1, 4)); - public TileCellData WallCenter = new TileCellData(0, new Vector2I(2, 4)); - public TileCellData WallRight = new TileCellData(0, new Vector2I(3, 4)); - public TileCellData WallSingle = new TileCellData(0, new Vector2I(4, 4)); + public TileCellData TopMask; + public TileCellData Wall_Bottom; + public TileCellData Wall_Left; + public TileCellData Wall_Right; + public TileCellData Wall_Top; + public TileCellData Wall_Out_LB; + public TileCellData Wall_Out_LT; + public TileCellData Wall_Out_RB; + public TileCellData Wall_Out_RT; + + + public TileCellData WallVertical_Left = new TileCellData(0, new Vector2I(1, 4)); + public TileCellData WallVertical_Center = new TileCellData(0, new Vector2I(2, 4)); + public TileCellData WallVertical_Right = new TileCellData(0, new Vector2I(3, 4)); + public TileCellData WallVertical_Single = new TileCellData(0, new Vector2I(4, 4)); //----------------------------- 所有自动图块数据 ----------------------------- //----------------------------- 命名规则: Auto_ + LT + T + RT + _ + L + C + R + _ + LB + B + RB @@ -112,6 +96,26 @@ public TileCellData Auto_010_110_110; public TileCellData Auto_110_110_010; public TileCellData Auto_010_111_011; + //第九列 + public TileCellData Auto_000_011_011; + public TileCellData Auto_011_011_011; + public TileCellData Auto_011_111_011; + public TileCellData Auto_011_011_000; + //第十列 + public TileCellData Auto_010_111_111; + public TileCellData Auto_110_111_011; + public TileCellData Auto_111_111_111; + public TileCellData Auto_111_111_000; + //第十一列 + public TileCellData Auto_000_111_111; + public TileCellData Auto_011_111_110; + public TileCellData Auto_111_111_010; + //第十二列 + public TileCellData Auto_000_110_110; + public TileCellData Auto_110_111_110; + public TileCellData Auto_110_110_110; + public TileCellData Auto_110_110_000; + //------------------------------------------------------------------------- public AutoTileConfig(int sourceId, TileSetAtlasSource atlasSource) @@ -121,11 +125,21 @@ { var pos = atlasSource.GetTileId(i); var tileData = atlasSource.GetTileData(pos, 0); - if (tileData.Terrain != -1 && tileData.TerrainSet != -1) //判断是否使用掩码 + if (tileData != null && tileData.Terrain != -1 && tileData.TerrainSet != -1) //判断是否使用掩码 { HandlerTileData(tileData.GetTerrainPeeringValue(), sourceId, pos); } } + + TopMask = Auto_111_111_111; + Wall_Bottom = Auto_000_111_111; + Wall_Left = Auto_110_110_110; + Wall_Right = Auto_011_011_011; + Wall_Top = Auto_111_111_000; + Wall_Out_LB = Auto_011_011_000; + Wall_Out_LT = Auto_000_011_011; + Wall_Out_RB = Auto_110_110_000; + Wall_Out_RT = Auto_000_110_110; } public int GetLayer2(Vector2I atlasCoords) @@ -135,7 +149,7 @@ private void HandlerTileData(uint peeringValue, int sourceId, Vector2I pos) { - var temp = new TileCellData(sourceId, pos); + var temp = new TileCellData(sourceId, pos, peeringValue); switch (peeringValue) { case TerrainPeering.Center | TerrainPeering.Bottom: @@ -150,7 +164,6 @@ case TerrainPeering.Center: Auto_000_010_000 = temp; break; - case TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: Auto_000_011_010 = temp; break; @@ -163,11 +176,11 @@ case TerrainPeering.Center | TerrainPeering.Right: Auto_000_011_000 = temp; break; - case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: Auto_000_111_010 = temp; break; - case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: + case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | + TerrainPeering.Bottom: Auto_010_111_010 = temp; break; case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right: @@ -176,7 +189,6 @@ case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right: Auto_000_111_000 = temp; break; - case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Bottom: Auto_000_110_010 = temp; break; @@ -189,7 +201,128 @@ case TerrainPeering.Left | TerrainPeering.Center: Auto_000_110_000 = temp; break; - + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right | TerrainPeering.Bottom: + Auto_110_111_010 = temp; + break; + case TerrainPeering.Top | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | + TerrainPeering.RightBottom: + Auto_010_011_011 = temp; + break; + case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Center | TerrainPeering.Right | + TerrainPeering.Bottom: + Auto_011_011_010 = temp; + break; + case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | + TerrainPeering.LeftBottom | TerrainPeering.Bottom: + Auto_010_111_110 = temp; + break; + case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | + TerrainPeering.RightBottom: + Auto_000_111_011 = temp; + break; + case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_011_111_111 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | + TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_111_111_011 = temp; + break; + case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right: + Auto_011_111_000 = temp; + break; + case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | + TerrainPeering.Bottom: + Auto_000_111_110 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_110_111_111 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | + TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom: + Auto_111_111_110 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right: + Auto_110_111_000 = temp; + break; + case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right | TerrainPeering.Bottom: + Auto_011_111_010 = temp; + break; + case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.LeftBottom | + TerrainPeering.Bottom: + Auto_010_110_110 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Bottom: + Auto_110_110_010 = temp; + break; + case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | + TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_010_111_011 = temp; + break; + case TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_000_011_011 = temp; + break; + case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Center | TerrainPeering.Right | + TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_011_011_011 = temp; + break; + case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_011_111_011 = temp; + break; + case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Center | TerrainPeering.Right: + Auto_011_011_000 = temp; + break; + case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | + TerrainPeering.LeftBottom | TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_010_111_111 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_110_111_011 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | + TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom | + TerrainPeering.RightBottom: + Auto_111_111_111 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | + TerrainPeering.Center | TerrainPeering.Right: + Auto_111_111_000 = temp; + break; + case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | + TerrainPeering.Bottom | TerrainPeering.RightBottom: + Auto_000_111_111 = temp; + break; + case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom: + Auto_011_111_110 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | + TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: + Auto_111_111_010 = temp; + break; + case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.LeftBottom | TerrainPeering.Bottom: + Auto_000_110_110 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom: + Auto_110_111_110 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | + TerrainPeering.LeftBottom | TerrainPeering.Bottom: + Auto_110_110_110 = temp; + break; + case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center: + Auto_110_110_000 = temp; + break; + default: Debug.LogError("未知PeeringValue: " + peeringValue); break; diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index b9be331..1010d3b 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -199,7 +199,7 @@ World = GameApplication.Instance.CreateNewWorld(); yield return 0; //生成地牢房间 - var random = new SeedRandom(); + var random = new SeedRandom(1); _dungeonGenerator = new DungeonGenerator(CurrConfig, random); _dungeonGenerator.Generate(); yield return 0; diff --git a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs index bf91b08..db2fcee 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs @@ -755,19 +755,19 @@ TileCellData tileCellData; if (left && right) { - tileCellData = _autoTileConfig.WallSingle; + tileCellData = _autoTileConfig.WallVertical_Single; } else if (left) { - tileCellData = _autoTileConfig.WallLeft; + tileCellData = _autoTileConfig.WallVertical_Left; } else if (right) { - tileCellData = _autoTileConfig.WallRight; + tileCellData = _autoTileConfig.WallVertical_Right; } else { - tileCellData = _autoTileConfig.WallCenter; + tileCellData = _autoTileConfig.WallVertical_Center; } SetCell(GetFloorLayer(), new Vector2I(x, y - 1), tileCellData.SourceId, tileCellData.AutoTileCoords); }