diff --git a/DungeonShooting_Godot/prefab/ui/MapEditorMapLayer.tscn b/DungeonShooting_Godot/prefab/ui/MapEditorMapLayer.tscn index 4423491..64daa22 100644 --- a/DungeonShooting_Godot/prefab/ui/MapEditorMapLayer.tscn +++ b/DungeonShooting_Godot/prefab/ui/MapEditorMapLayer.tscn @@ -22,9 +22,17 @@ grow_horizontal = 2 grow_vertical = 2 -[node name="LayerLabel" type="Label" parent="VBoxContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 -text = "地图层级:" + +[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "淡化未选中的层" + +[node name="CheckButton" type="CheckButton" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +flat = true [node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"] layout_mode = 2 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png index 3078ae9..fc3efd3 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/TileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/TileInfo.json index a92ac30..0f209e6 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/TileInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/TileInfo.json @@ -1 +1 @@ -{"NavigationVertices":[{"X":202,"Y":-58},{"X":202,"Y":66},{"X":198,"Y":38},{"X":198,"Y":-14},{"X":-58,"Y":66},{"X":170,"Y":38},{"X":38,"Y":-10},{"X":38,"Y":-46},{"X":170,"Y":-14},{"X":-22,"Y":-10},{"X":-58,"Y":-58},{"X":-22,"Y":-46}],"NavigationPolygon":[[0,1,2,3],[2,1,4,5],[6,7,8,5],[6,5,4,9],[9,4,10,11],[11,10,0,7],[8,7,0,3]],"Floor":[3,-2,0,3,2,-2,0,3,-2,-2,0,3,-2,-1,0,3,-1,-1,0,3,0,-1,0,3,1,-1,0,3,2,-1,0,3,3,-1,0,3,3,0,0,3,2,0,0,3,1,0,0,3,0,0,0,3,-1,0,0,3,-2,0,0,3,-2,1,0,3,-1,1,0,3,0,1,0,3,1,1,0,3,2,1,0,3,3,1,0,3,3,-3,0,3,2,-3,0,3,-2,-3,0,3,4,-3,0,3,5,-3,0,3,6,-3,0,3,7,-3,0,3,8,-2,0,3,9,-2,0,3,7,-2,0,3,6,-2,0,3,5,-2,0,3,4,-2,0,3,8,-3,0,3,9,-3,0,3,10,-3,0,3,9,-4,0,3,8,-4,0,3,7,-4,0,3,6,-4,0,3,5,-4,0,3,4,-4,0,3,3,-4,0,3,2,-4,0,3,1,-4,0,3,0,-4,0,3,-1,-4,0,3,-2,-4,0,3,-3,-4,0,3,-3,-3,0,3,-3,-2,0,3,-3,-1,0,3,-3,0,0,3,-3,1,0,3,-4,1,0,3,-4,2,0,3,-3,2,0,3,-2,2,0,3,-1,2,0,3,0,2,0,3,1,2,0,3,2,2,0,3,3,2,0,3,4,2,0,3,4,1,0,3,4,0,0,3,4,-1,0,3,5,-1,0,3,6,-1,0,3,7,-1,0,3,8,-1,0,3,9,-1,0,3,10,-1,0,3,10,-2,0,3,10,0,0,3,9,0,0,3,8,0,0,3,7,0,0,3,6,0,0,3,5,0,0,3,5,1,0,3,6,1,0,3,7,1,0,3,8,1,0,3,9,1,0,3,9,2,0,3,10,2,0,3,8,2,0,3,7,2,0,3,6,2,0,3,5,2,0,3,10,1,0,3,10,3,0,3,9,3,0,3,8,3,0,3,7,3,0,3,6,3,0,3,5,3,0,3,4,3,0,3,3,3,0,3,2,3,0,3,1,3,0,3,0,3,0,3,-1,3,0,3,-2,3,0,3,-3,3,0,3,-4,0,0,3,-4,-1,0,3,-4,-2,0,3,-4,-3,0,3,-4,-4,0,3,-4,3,0,3,10,-4,0,3,12,-4,0,3,12,-3,0,3,12,-2,0,3,11,-2,0,3,11,-3,0,3,11,-4,0,3,12,-1,0,3,12,0,0,3,12,1,0,3,12,2,0,3,12,3,0,3,11,3,0,3,11,2,0,3],"Middle":[-4,-6,63,1,-4,-5,2,2,-3,-6,63,1,-3,-5,2,2,-2,-6,63,1,-2,-5,2,2,-1,-6,63,1,-1,-5,2,2,-1,-3,48,1,-1,-2,1,2,0,-6,63,1,0,-5,2,2,0,-3,56,1,0,-2,2,2,1,-6,63,1,1,-5,2,2,1,-3,24,1,1,-2,3,2,2,-6,63,1,2,-5,2,2,3,-6,63,1,3,-5,2,2,4,-6,63,1,4,-5,2,2,5,-6,63,1,5,-5,2,2,6,-6,63,1,6,-5,2,2,7,-6,63,1,7,-5,2,2,8,-6,63,1,8,-5,2,2,9,-6,63,1,9,-5,2,2,10,-6,63,1,10,-5,2,2,11,-6,63,1,11,-5,2,2,11,0,18,1,11,1,0,2,12,-6,63,1,12,-5,2,2],"Top":[-6,-7,511,1,-6,-6,511,1,-6,-5,511,1,-6,-4,511,1,-6,-3,511,1,-6,-2,511,1,-6,-1,511,1,-6,0,511,1,-6,1,511,1,-6,2,511,1,-6,3,511,1,-6,4,511,1,-6,5,511,1,-5,-7,511,1,-5,-6,255,1,-5,-5,219,1,-5,-4,219,1,-5,-3,219,1,-5,-2,219,1,-5,-1,219,1,-5,0,219,1,-5,1,219,1,-5,2,219,1,-5,3,219,1,-5,4,507,1,-5,5,511,1,-4,-7,511,1,-4,4,504,1,-4,5,511,1,-3,-7,511,1,-3,4,504,1,-3,5,511,1,-2,-7,511,1,-2,4,504,1,-2,5,511,1,-1,-7,511,1,-1,4,504,1,-1,5,511,1,0,-7,511,1,0,4,504,1,0,5,511,1,1,-7,511,1,1,4,504,1,1,5,511,1,2,-7,511,1,2,4,504,1,2,5,511,1,3,-7,511,1,3,4,504,1,3,5,511,1,4,-7,511,1,4,4,504,1,4,5,511,1,5,-7,511,1,5,4,504,1,5,5,511,1,6,-7,511,1,6,4,504,1,6,5,511,1,7,-7,511,1,7,4,504,1,7,5,511,1,8,-7,511,1,8,4,504,1,8,5,511,1,9,-7,511,1,9,4,504,1,9,5,511,1,10,-7,511,1,10,4,504,1,10,5,511,1,11,-7,511,1,11,-1,144,1,11,4,504,1,11,5,511,1,12,-7,511,1,12,4,504,1,12,5,511,1,13,-7,511,1,13,-6,447,1,13,-5,438,1,13,-4,438,1,13,-3,438,1,13,-2,438,1,13,-1,438,1,13,0,438,1,13,1,438,1,13,2,438,1,13,3,438,1,13,4,510,1,13,5,511,1,14,-7,511,1,14,-6,511,1,14,-5,511,1,14,-4,511,1,14,-3,511,1,14,-2,511,1,14,-1,511,1,14,0,511,1,14,1,511,1,14,2,511,1,14,3,511,1,14,4,511,1,14,5,511,1],"CustomFloor1":[],"CustomFloor2":[],"CustomFloor3":[],"CustomMiddle1":[],"CustomMiddle2":[],"CustomTop":[]} \ No newline at end of file +{"NavigationVertices":[{"X":202,"Y":-58},{"X":202,"Y":66},{"X":198,"Y":38},{"X":198,"Y":-14},{"X":-58,"Y":66},{"X":170,"Y":38},{"X":38,"Y":-10},{"X":38,"Y":-46},{"X":170,"Y":-14},{"X":-22,"Y":-10},{"X":-58,"Y":-58},{"X":-22,"Y":-46}],"NavigationPolygon":[[0,1,2,3],[2,1,4,5],[6,7,8,5],[6,5,4,9],[9,4,10,11],[11,10,0,7],[8,7,0,3]],"Floor":[3,-2,0,3,2,-2,0,3,-2,-2,0,3,-2,-1,0,3,-1,-1,0,3,0,-1,0,3,1,-1,0,3,2,-1,0,3,3,-1,0,3,3,0,0,3,2,0,0,3,1,0,0,3,0,0,0,3,-1,0,0,3,-2,0,0,3,-2,1,0,3,-1,1,0,3,0,1,0,3,1,1,0,3,2,1,0,3,3,1,0,3,3,-3,0,3,2,-3,0,3,-2,-3,0,3,4,-3,0,3,5,-3,0,3,6,-3,0,3,7,-3,0,3,8,-2,0,3,9,-2,0,3,7,-2,0,3,6,-2,0,3,5,-2,0,3,4,-2,0,3,8,-3,0,3,9,-3,0,3,10,-3,0,3,9,-4,0,3,8,-4,0,3,7,-4,0,3,6,-4,0,3,5,-4,0,3,4,-4,0,3,3,-4,0,3,2,-4,0,3,1,-4,0,3,0,-4,0,3,-1,-4,0,3,-2,-4,0,3,-3,-4,0,3,-3,-3,0,3,-3,-2,0,3,-3,-1,0,3,-3,0,0,3,-3,1,0,3,-4,1,0,3,-4,2,0,3,-3,2,0,3,-2,2,0,3,-1,2,0,3,0,2,0,3,1,2,0,3,2,2,0,3,3,2,0,3,4,2,0,3,4,1,0,3,4,0,0,3,4,-1,0,3,5,-1,0,3,6,-1,0,3,7,-1,0,3,8,-1,0,3,9,-1,0,3,10,-1,0,3,10,-2,0,3,10,0,0,3,9,0,0,3,8,0,0,3,7,0,0,3,6,0,0,3,5,0,0,3,5,1,0,3,6,1,0,3,7,1,0,3,8,1,0,3,9,1,0,3,9,2,0,3,10,2,0,3,8,2,0,3,7,2,0,3,6,2,0,3,5,2,0,3,10,1,0,3,10,3,0,3,9,3,0,3,8,3,0,3,7,3,0,3,6,3,0,3,5,3,0,3,4,3,0,3,3,3,0,3,2,3,0,3,1,3,0,3,0,3,0,3,-1,3,0,3,-2,3,0,3,-3,3,0,3,-4,0,0,3,-4,-1,0,3,-4,-2,0,3,-4,-3,0,3,-4,-4,0,3,-4,3,0,3,10,-4,0,3,12,-4,0,3,12,-3,0,3,12,-2,0,3,11,-2,0,3,11,-3,0,3,11,-4,0,3,12,-1,0,3,12,0,0,3,12,1,0,3,12,2,0,3,12,3,0,3,11,3,0,3,11,2,0,3],"Middle":[-4,-6,63,1,-4,-5,2,2,-3,-6,63,1,-3,-5,2,2,-2,-6,63,1,-2,-5,2,2,-1,-6,63,1,-1,-5,2,2,-1,-3,48,1,-1,-2,1,2,0,-6,63,1,0,-5,2,2,0,-3,56,1,0,-2,2,2,1,-6,63,1,1,-5,2,2,1,-3,24,1,1,-2,3,2,2,-6,63,1,2,-5,2,2,3,-6,63,1,3,-5,2,2,4,-6,63,1,4,-5,2,2,5,-6,63,1,5,-5,2,2,6,-6,63,1,6,-5,2,2,7,-6,63,1,7,-5,2,2,8,-6,63,1,8,-5,2,2,9,-6,63,1,9,-5,2,2,10,-6,63,1,10,-5,2,2,11,-6,63,1,11,-5,2,2,11,0,18,1,11,1,0,2,12,-6,63,1,12,-5,2,2],"Top":[-6,-7,511,1,-6,-6,511,1,-6,-5,511,1,-6,-4,511,1,-6,-3,511,1,-6,-2,511,1,-6,-1,511,1,-6,0,511,1,-6,1,511,1,-6,2,511,1,-6,3,511,1,-6,4,511,1,-6,5,511,1,-5,-7,511,1,-5,-6,255,1,-5,-5,219,1,-5,-4,219,1,-5,-3,219,1,-5,-2,219,1,-5,-1,219,1,-5,0,219,1,-5,1,219,1,-5,2,219,1,-5,3,219,1,-5,4,507,1,-5,5,511,1,-4,-7,511,1,-4,4,504,1,-4,5,511,1,-3,-7,511,1,-3,4,504,1,-3,5,511,1,-2,-7,511,1,-2,4,504,1,-2,5,511,1,-1,-7,511,1,-1,4,504,1,-1,5,511,1,0,-7,511,1,0,4,504,1,0,5,511,1,1,-7,511,1,1,4,504,1,1,5,511,1,2,-7,511,1,2,4,504,1,2,5,511,1,3,-7,511,1,3,4,504,1,3,5,511,1,4,-7,511,1,4,4,504,1,4,5,511,1,5,-7,511,1,5,4,504,1,5,5,511,1,6,-7,511,1,6,4,504,1,6,5,511,1,7,-7,511,1,7,4,504,1,7,5,511,1,8,-7,511,1,8,4,504,1,8,5,511,1,9,-7,511,1,9,4,504,1,9,5,511,1,10,-7,511,1,10,4,504,1,10,5,511,1,11,-7,511,1,11,-1,144,1,11,4,504,1,11,5,511,1,12,-7,511,1,12,4,504,1,12,5,511,1,13,-7,511,1,13,-6,447,1,13,-5,438,1,13,-4,438,1,13,-3,438,1,13,-2,438,1,13,-1,438,1,13,0,438,1,13,1,438,1,13,2,438,1,13,3,438,1,13,4,510,1,13,5,511,1,14,-7,511,1,14,-6,511,1,14,-5,511,1,14,-4,511,1,14,-3,511,1,14,-2,511,1,14,-1,511,1,14,0,511,1,14,1,511,1,14,2,511,1,14,3,511,1,14,4,511,1,14,5,511,1],"CustomFloor1":[],"CustomFloor2":[],"CustomFloor3":[],"CustomMiddle1":[4,-1,1,12,10,4,-2,1,12,9,4,-3,1,12,8,5,-3,1,13,8,6,-3,1,14,8,6,-2,1,14,9,6,-1,1,14,10,7,-1,1,15,10,7,-2,1,15,9,7,-3,1,15,8,-1,2,1,12,10,-1,1,1,12,9,-1,0,1,12,8,0,0,1,13,8,1,0,1,14,8,1,1,1,14,9,1,2,1,14,10,2,2,1,15,10,2,1,1,15,9,2,0,1,15,8,5,2,1,12,10,5,1,1,12,9,5,0,1,12,8,6,0,1,13,8,7,0,1,14,8,7,1,1,14,9,7,2,1,14,10,8,2,1,15,10,8,1,1,15,9,8,0,1,15,8],"CustomMiddle2":[],"CustomTop":[]} \ No newline at end of file diff --git a/DungeonShooting_Godot/scene/World.tscn b/DungeonShooting_Godot/scene/World.tscn index 78e6177..aa995e7 100644 --- a/DungeonShooting_Godot/scene/World.tscn +++ b/DungeonShooting_Godot/scene/World.tscn @@ -26,21 +26,6 @@ [node name="TileRoot" type="TileMap" parent="." groups=["navigation"]] y_sort_enabled = true format = 2 -layer_0/name = "Floor" -layer_0/z_index = -10 -layer_0/navigation_enabled = false -layer_1/name = "Middle" -layer_1/y_sort_enabled = true -layer_1/navigation_enabled = false -layer_1/tile_data = PackedInt32Array() -layer_2/name = "Top" -layer_2/z_index = 10 -layer_2/navigation_enabled = false -layer_2/tile_data = PackedInt32Array() -layer_3/name = "AisleFloor" -layer_3/z_index = -10 -layer_3/navigation_enabled = false -layer_3/tile_data = PackedInt32Array() [node name="NavigationRoot" type="Node2D" parent="TileRoot"] z_index = -2 diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs index 6ef9196..1aef2f9 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs @@ -54,24 +54,24 @@ //铺房间 if (roomInfo.RoomSplit == null) //自动填充的矩形房间, 现已经弃用 { - FillRect(GameConfig.FloorMapLayer, config.Floor, roomInfo.Position + Vector2.One, + FillRect(MapLayer.AutoFloorLayer, config.Floor, roomInfo.Position + Vector2.One, roomInfo.Size - new Vector2(2, 2)); - FillRect(GameConfig.TopMapLayer, config.Wall_In_LT, roomInfo.Position, Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_Left, roomInfo.Position + new Vector2(0, 1), + FillRect(MapLayer.AutoTopLayer, config.Wall_In_LT, roomInfo.Position, Vector2.One); + FillRect(MapLayer.AutoTopLayer, config.Wall_Left, roomInfo.Position + new Vector2(0, 1), new Vector2(1, roomInfo.Size.Y - 2)); - FillRect(GameConfig.TopMapLayer, config.Wall_In_LB, roomInfo.Position + new Vector2(0, roomInfo.Size.Y - 1), + FillRect(MapLayer.AutoTopLayer, config.Wall_In_LB, roomInfo.Position + new Vector2(0, roomInfo.Size.Y - 1), new Vector2(1, 1)); - FillRect(GameConfig.TopMapLayer, config.Wall_Bottom, roomInfo.Position + new Vector2(1, roomInfo.Size.Y - 1), + FillRect(MapLayer.AutoTopLayer, config.Wall_Bottom, roomInfo.Position + new Vector2(1, roomInfo.Size.Y - 1), new Vector2(roomInfo.Size.X - 2, 1)); - FillRect(GameConfig.TopMapLayer, config.Wall_In_RB, + FillRect(MapLayer.AutoTopLayer, config.Wall_In_RB, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, roomInfo.Size.Y - 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_Right, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, 1), + FillRect(MapLayer.AutoTopLayer, config.Wall_Right, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, 1), new Vector2(1, roomInfo.Size.Y - 2)); - FillRect(GameConfig.TopMapLayer, config.Wall_In_RT, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, 0), + FillRect(MapLayer.AutoTopLayer, config.Wall_In_RT, roomInfo.Position + new Vector2(roomInfo.Size.X - 1, 0), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, roomInfo.Position + Vector2.Right, + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Top, roomInfo.Position + Vector2.Right, new Vector2(roomInfo.Size.X - 2, 1)); } else @@ -111,45 +111,21 @@ //---------------------- 填充tile操作 ---------------------- var terrainInfo = config.TerrainInfo; + //自动地形层 //底层 - for (var i = 0; i < tileInfo.Floor.Count; i += 4) - { - var posX = tileInfo.Floor[i]; - var posY = tileInfo.Floor[i + 1]; - var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); - var bit = (uint)tileInfo.Floor[i + 2]; - var type = (byte)tileInfo.Floor[i + 3]; - var index = terrainInfo.TerrainBitToIndex(bit, type); - var terrainCell = terrainInfo.GetTerrainCell(index, type); - var atlasCoords = terrainInfo.GetPosition(terrainCell); - _tileRoot.SetCell(GameConfig.FloorMapLayer, pos, config.SourceId, atlasCoords); - } + SetAutoLayerDataFromList(MapLayer.AutoFloorLayer, config.SourceId, roomInfo, tileInfo.Floor, rectPos, terrainInfo); //中层 - for (var i = 0; i < tileInfo.Middle.Count; i += 4) - { - var posX = tileInfo.Middle[i]; - var posY = tileInfo.Middle[i + 1]; - var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); - var bit = (uint)tileInfo.Middle[i + 2]; - var type = (byte)tileInfo.Middle[i + 3]; - var index = terrainInfo.TerrainBitToIndex(bit, type); - var terrainCell = terrainInfo.GetTerrainCell(index, type); - var atlasCoords = terrainInfo.GetPosition(terrainCell); - _tileRoot.SetCell(GameConfig.MiddleMapLayer, pos, config.SourceId, atlasCoords); - } + SetAutoLayerDataFromList(MapLayer.AutoMiddleLayer, config.SourceId, roomInfo, tileInfo.Middle, rectPos, terrainInfo); //顶层 - for (var i = 0; i < tileInfo.Top.Count; i += 4) - { - var posX = tileInfo.Top[i]; - var posY = tileInfo.Top[i + 1]; - var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); - var bit = (uint)tileInfo.Top[i + 2]; - var type = (byte)tileInfo.Top[i + 3]; - var index = terrainInfo.TerrainBitToIndex(bit, type); - var terrainCell = terrainInfo.GetTerrainCell(index, type); - var atlasCoords = terrainInfo.GetPosition(terrainCell); - _tileRoot.SetCell(GameConfig.TopMapLayer, pos, config.SourceId, atlasCoords); - } + SetAutoLayerDataFromList(MapLayer.AutoTopLayer, config.SourceId, roomInfo, tileInfo.Top, rectPos, terrainInfo); + + //自定义数据层 + SetCustomLayerDataFromList(MapLayer.CustomFloorLayer1, roomInfo, tileInfo.CustomFloor1, rectPos); + SetCustomLayerDataFromList(MapLayer.CustomFloorLayer2, roomInfo, tileInfo.CustomFloor2, rectPos); + SetCustomLayerDataFromList(MapLayer.CustomFloorLayer3, roomInfo, tileInfo.CustomFloor3, rectPos); + SetCustomLayerDataFromList(MapLayer.CustomMiddleLayer1, roomInfo, tileInfo.CustomMiddle1, rectPos); + SetCustomLayerDataFromList(MapLayer.CustomMiddleLayer2, roomInfo, tileInfo.CustomMiddle2, rectPos); + SetCustomLayerDataFromList(MapLayer.CustomTopLayer, roomInfo, tileInfo.CustomTop, rectPos); //寻找可用传送点 var maxCount = (roomInfo.Size.X - 2) * (roomInfo.Size.Y - 2); @@ -157,7 +133,7 @@ for (int i = 0; i < maxCount; i++) { var pos = SpiralUtil.Screw(i) + startPosition; - if (IsWayTile(GameConfig.FloorMapLayer, pos.X, pos.Y)) + if (IsWayTile(MapLayer.AutoFloorLayer, pos.X, pos.Y)) { roomInfo.Waypoints = pos; break; @@ -242,7 +218,7 @@ var rect2 = aisleRect.Rect2; //填充交叉点 - FillRect(GameConfig.AisleFloorMapLayer, config.Floor, aisleRect.Cross.Position, aisleRect.Cross.Size); + FillRect(MapLayer.AutoAisleFloorLayer, config.Floor, aisleRect.Cross.Position, aisleRect.Cross.Size); //墙壁, 0横向, 1纵向 if (dir1 == 0) @@ -275,50 +251,50 @@ if ((doorDir1 == DoorDirection.N && doorDir2 == DoorDirection.E) || //↑→ (doorDir2 == DoorDirection.N && doorDir1 == DoorDirection.E)) { - FillRect(GameConfig.TopMapLayer, config.Wall_Out_RT, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_In_RT, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, -1), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, doorInfo.Cross + new Vector2I(0, -1), new Vector2(GameConfig.CorridorWidth - 1, 1)); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Vertical_Center, doorInfo.Cross, new Vector2(GameConfig.CorridorWidth - 1, 1)); - FillRect(GameConfig.TopMapLayer, config.Wall_Right, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 0), new Vector2(1, GameConfig.CorridorWidth)); + FillRect(MapLayer.AutoTopLayer, config.Wall_Out_RT, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), Vector2.One); + FillRect(MapLayer.AutoTopLayer, config.Wall_In_RT, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, -1), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Top, doorInfo.Cross + new Vector2I(0, -1), new Vector2(GameConfig.CorridorWidth - 1, 1)); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Center, doorInfo.Cross, new Vector2(GameConfig.CorridorWidth - 1, 1)); + FillRect(MapLayer.AutoTopLayer, config.Wall_Right, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 0), new Vector2(1, GameConfig.CorridorWidth)); - FillRect(GameConfig.TopMapLayer, config.TopMask, doorInfo.Cross - new Vector2I(0, 2), new Vector2(GameConfig.CorridorWidth + 1, 1)); - FillRect(GameConfig.TopMapLayer, config.TopMask, doorInfo.Cross + new Vector2I(GameConfig.CorridorWidth, -1), new Vector2(1, GameConfig.CorridorWidth + 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, doorInfo.Cross - new Vector2I(0, 2), new Vector2(GameConfig.CorridorWidth + 1, 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, doorInfo.Cross + new Vector2I(GameConfig.CorridorWidth, -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.Wall_Out_RB, doorInfo.Cross + new Vector2I(0, -1), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Vertical_Right, doorInfo.Cross, Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_In_RB, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, GameConfig.CorridorWidth - 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_Right, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, -1), new Vector2(1, GameConfig.CorridorWidth)); - FillRect(GameConfig.TopMapLayer, config.Wall_Bottom, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), new Vector2(GameConfig.CorridorWidth - 1, 1)); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Out_RB, doorInfo.Cross + new Vector2I(0, -1), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Right, doorInfo.Cross, Vector2.One); + FillRect(MapLayer.AutoTopLayer, config.Wall_In_RB, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, GameConfig.CorridorWidth - 1), Vector2.One); + FillRect(MapLayer.AutoTopLayer, config.Wall_Right, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, -1), new Vector2(1, GameConfig.CorridorWidth)); + FillRect(MapLayer.AutoTopLayer, config.Wall_Bottom, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), new Vector2(GameConfig.CorridorWidth - 1, 1)); - FillRect(GameConfig.TopMapLayer, config.TopMask, doorInfo.Cross + new Vector2I(GameConfig.CorridorWidth, -1), new Vector2(1, GameConfig.CorridorWidth + 1)); - FillRect(GameConfig.TopMapLayer, config.TopMask, doorInfo.Cross + new Vector2I(0, GameConfig.CorridorWidth), new Vector2(GameConfig.CorridorWidth + 1, 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, doorInfo.Cross + new Vector2I(GameConfig.CorridorWidth, -1), new Vector2(1, GameConfig.CorridorWidth + 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, doorInfo.Cross + new Vector2I(0, GameConfig.CorridorWidth), new Vector2(GameConfig.CorridorWidth + 1, 1)); } else if ((doorDir1 == DoorDirection.S && doorDir2 == DoorDirection.W) || //↓← (doorDir2 == DoorDirection.S && doorDir1 == DoorDirection.W)) { - FillRect(GameConfig.MiddleMapLayer, config.Wall_Out_LB, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, -1), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Vertical_Left, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 0), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_In_LB, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_Left, doorInfo.Cross + new Vector2I(0, -1), new Vector2(1, GameConfig.CorridorWidth)); - FillRect(GameConfig.TopMapLayer, config.Wall_Bottom, doorInfo.Cross + new Vector2(1, GameConfig.CorridorWidth - 1), new Vector2(GameConfig.CorridorWidth - 1, 1)); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Out_LB, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, -1), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Left, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, 0), Vector2.One); + FillRect(MapLayer.AutoTopLayer, config.Wall_In_LB, doorInfo.Cross + new Vector2(0, GameConfig.CorridorWidth - 1), Vector2.One); + FillRect(MapLayer.AutoTopLayer, config.Wall_Left, doorInfo.Cross + new Vector2I(0, -1), new Vector2(1, GameConfig.CorridorWidth)); + FillRect(MapLayer.AutoTopLayer, config.Wall_Bottom, doorInfo.Cross + new Vector2(1, GameConfig.CorridorWidth - 1), new Vector2(GameConfig.CorridorWidth - 1, 1)); - FillRect(GameConfig.TopMapLayer, config.TopMask, doorInfo.Cross + new Vector2I(-1, -1), new Vector2(1, GameConfig.CorridorWidth + 1)); - FillRect(GameConfig.TopMapLayer, config.TopMask, doorInfo.Cross + new Vector2I(-1, GameConfig.CorridorWidth), new Vector2(GameConfig.CorridorWidth + 1, 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, doorInfo.Cross + new Vector2I(-1, -1), new Vector2(1, GameConfig.CorridorWidth + 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, doorInfo.Cross + new Vector2I(-1, GameConfig.CorridorWidth), new Vector2(GameConfig.CorridorWidth + 1, 1)); } else if ((doorDir1 == DoorDirection.W && doorDir2 == DoorDirection.N) || //←↑ (doorDir2 == DoorDirection.W && doorDir1 == DoorDirection.N)) { - FillRect(GameConfig.TopMapLayer, config.Wall_Out_LT, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, GameConfig.CorridorWidth - 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_In_LT, doorInfo.Cross + new Vector2I(0, -1), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Top, doorInfo.Cross + new Vector2(1, -1), new Vector2(GameConfig.CorridorWidth - 1, 1)); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Vertical_Center, doorInfo.Cross + new Vector2(1, 0), new Vector2(GameConfig.CorridorWidth - 1, 1)); - FillRect(GameConfig.TopMapLayer, config.Wall_Left, doorInfo.Cross + new Vector2(0, 0), new Vector2(1, GameConfig.CorridorWidth)); + FillRect(MapLayer.AutoTopLayer, config.Wall_Out_LT, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, GameConfig.CorridorWidth - 1), Vector2.One); + FillRect(MapLayer.AutoTopLayer, config.Wall_In_LT, doorInfo.Cross + new Vector2I(0, -1), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Top, doorInfo.Cross + new Vector2(1, -1), new Vector2(GameConfig.CorridorWidth - 1, 1)); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Center, doorInfo.Cross + new Vector2(1, 0), new Vector2(GameConfig.CorridorWidth - 1, 1)); + FillRect(MapLayer.AutoTopLayer, config.Wall_Left, doorInfo.Cross + new Vector2(0, 0), new Vector2(1, GameConfig.CorridorWidth)); - FillRect(GameConfig.TopMapLayer, config.TopMask, doorInfo.Cross - new Vector2I(1, 2), new Vector2(GameConfig.CorridorWidth + 1, 1)); - FillRect(GameConfig.TopMapLayer, config.TopMask, doorInfo.Cross - new Vector2I(1, 1), new Vector2(1, GameConfig.CorridorWidth + 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, doorInfo.Cross - new Vector2I(1, 2), new Vector2(GameConfig.CorridorWidth + 1, 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, doorInfo.Cross - new Vector2I(1, 1), new Vector2(1, GameConfig.CorridorWidth + 1)); } } @@ -356,6 +332,38 @@ } } + //设置自动地形层的数据 + private void SetAutoLayerDataFromList(int layer, int sourceId, RoomInfo roomInfo, List data, Vector2I rectPos, TileSetTerrainInfo terrainInfo) + { + for (var i = 0; i < data.Count; i += 4) + { + var posX = data[i]; + var posY = data[i + 1]; + var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); + var bit = (uint)data[i + 2]; + var type = (byte)data[i + 3]; + var index = terrainInfo.TerrainBitToIndex(bit, type); + var terrainCell = terrainInfo.GetTerrainCell(index, type); + var atlasCoords = terrainInfo.GetPosition(terrainCell); + _tileRoot.SetCell(layer, pos, sourceId, atlasCoords); + } + } + + //设置自定义层的数据 + private void SetCustomLayerDataFromList(int layer, RoomInfo roomInfo, List data, Vector2I rectPos) + { + for (var i = 0; i < data.Count; i += 5) + { + var posX = data[i]; + var posY = data[i + 1]; + var sourceId = data[i + 2]; + var atlasCoordsX = data[i + 3]; + var atlasCoordsY = data[i + 4]; + var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); + _tileRoot.SetCell(layer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); + } + } + /// /// 给TileMap添加轮廓, 该函数为协程函数 /// @@ -376,10 +384,10 @@ yield return 0; } var pos = new Vector2I(x, y); - var flag1 = _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, pos) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, pos) != -1 || - _tileRoot.GetCellSourceId(GameConfig.AisleFloorMapLayer, pos) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, pos) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, pos) != tileCellData.AutoTileCoords); + var flag1 = _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, pos) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, pos) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoAisleFloorLayer, pos) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, pos) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, pos) != tileCellData.AutoTileCoords); if (!flag1) //空地 { var posDown = new Vector2I(pos.X, pos.Y + 1); @@ -392,41 +400,41 @@ var posRD = new Vector2I(pos.X + 1, pos.Y + 1); var posRT = new Vector2I(pos.X + 1, pos.Y - 1); - var flag2 = _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posDown) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posDown) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posDown) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posDown) != tileCellData.AutoTileCoords) || + var flag2 = _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, posDown) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, posDown) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, posDown) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, posDown) != tileCellData.AutoTileCoords) || - _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posTop) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posTop) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posTop) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posTop) != tileCellData.AutoTileCoords) || + _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, posTop) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, posTop) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, posTop) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, posTop) != tileCellData.AutoTileCoords) || - _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posLeft) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posLeft) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLeft) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLeft) != tileCellData.AutoTileCoords) || + _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, posLeft) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, posLeft) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, posLeft) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, posLeft) != tileCellData.AutoTileCoords) || - _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posRight) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posRight) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRight) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRight) != tileCellData.AutoTileCoords) || + _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, posRight) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, posRight) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, posRight) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, posRight) != tileCellData.AutoTileCoords) || // - _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posLD) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posLD) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLD) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLD) != tileCellData.AutoTileCoords) || + _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, posLD) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, posLD) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, posLD) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, posLD) != tileCellData.AutoTileCoords) || - _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posLT) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posLT) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLT) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLT) != tileCellData.AutoTileCoords) || + _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, posLT) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, posLT) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, posLT) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, posLT) != tileCellData.AutoTileCoords) || - _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posRD) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posRD) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRD) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRD) != tileCellData.AutoTileCoords) || + _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, posRD) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, posRD) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, posRD) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, posRD) != tileCellData.AutoTileCoords) || - _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posRT) != -1 || - _tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posRT) != -1 || - (_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRT) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRT) != tileCellData.AutoTileCoords); + _tileRoot.GetCellSourceId(MapLayer.AutoFloorLayer, posRT) != -1 || + _tileRoot.GetCellSourceId(MapLayer.AutoMiddleLayer, posRT) != -1 || + (_tileRoot.GetCellSourceId(MapLayer.AutoTopLayer, posRT) != -1 && _tileRoot.GetCellAtlasCoords(MapLayer.AutoTopLayer, posRT) != tileCellData.AutoTileCoords); if (flag2) //非空地, 那么说明这个点需要填充 WALL_BLOCK { - _tileRoot.SetCell(GameConfig.TopMapLayer, pos, tileCellData.SourceId, tileCellData.AutoTileCoords); + _tileRoot.SetCell(MapLayer.AutoTopLayer, pos, tileCellData.SourceId, tileCellData.AutoTileCoords); } } } @@ -441,7 +449,7 @@ for (int j = 0; j < size.Y; j++) { var p = new Vector2I((int)pos.X + i, (int)pos.Y + j); - if (layer == GameConfig.AisleFloorMapLayer) + if (layer == MapLayer.AutoAisleFloorLayer) { _tempAisleFloorGrid.Set(p, true); } @@ -458,7 +466,7 @@ for (int j = 0; j < size.Y; j++) { var p = new Vector2I((int)pos.X + i, (int)pos.Y + j); - if (layer == GameConfig.AisleFloorMapLayer) + if (layer == MapLayer.AutoAisleFloorLayer) { _tempAisleFloorGrid.Remove(p.X, p.Y); } @@ -470,42 +478,42 @@ //横向过道 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.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.Wall_Vertical_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)); + FillRect(MapLayer.AutoAisleFloorLayer, config.Floor, rect.Position + new Vector2(0, 1), rect.Size - new Vector2(0, 2)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, rect.Position - new Vector2(0, 2), new Vector2(rect.Size.X, 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, rect.Position + new Vector2(0, rect.Size.Y), new Vector2(rect.Size.X, 1)); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Top, rect.Position - new Vector2(0, 1), new Vector2(rect.Size.X, 1)); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Center, rect.Position, new Vector2(rect.Size.X, 1)); + FillRect(MapLayer.AutoTopLayer, 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.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)); + FillRect(MapLayer.AutoAisleFloorLayer, config.Floor, rect.Position + new Vector2(1, 0), rect.Size - new Vector2(2, 0)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, rect.Position - new Vector2(1, 0), new Vector2(1, rect.Size.Y - 1)); + FillRect(MapLayer.AutoTopLayer, config.TopMask, rect.Position + new Vector2(rect.Size.X, 0), new Vector2(1, rect.Size.Y - 1)); + FillRect(MapLayer.AutoTopLayer, config.Wall_Left, rect.Position, new Vector2(1, rect.Size.Y - 1)); + FillRect(MapLayer.AutoTopLayer, config.Wall_Right, rect.Position + new Vector2(rect.Size.X - 1, 0), new Vector2(1, rect.Size.Y - 1)); } //横向过道, 门朝右, 连接方向向左 private void FullHorizontalAisleLeft(AutoTileConfig config, Rect2 rect, RoomDoorInfo doorInfo = null) { //左 - ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.Y - 2)); + ClearRect(MapLayer.AutoTopLayer, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.Y - 2)); if (doorInfo == null) { - FillRect(GameConfig.AisleFloorMapLayer, config.Floor, rect.Position + new Vector2(-1, 1), + FillRect(MapLayer.AutoAisleFloorLayer, config.Floor, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.Y - 2)); } else { - ClearRect(GameConfig.TopMapLayer, rect.Position - new Vector2(1, 1), new Vector2(2, 4)); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Vertical_Left, rect.Position - new Vector2(1, 0), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Out_LB, rect.Position - new Vector2(1, 1), Vector2.One); - FillRect(GameConfig.TopMapLayer, config.Wall_Out_LT, rect.Position + new Vector2(-1, 3), Vector2.One); + ClearRect(MapLayer.AutoTopLayer, rect.Position - new Vector2(1, 1), new Vector2(2, 4)); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Left, rect.Position - new Vector2(1, 0), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Out_LB, rect.Position - new Vector2(1, 1), Vector2.One); + FillRect(MapLayer.AutoTopLayer, 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)); + FillRect(MapLayer.AutoFloorLayer, config.Floor, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.Y - 2)); //生成门的导航区域 var x = rect.Position.X * GameConfig.TileCellSize; var y = rect.Position.Y * GameConfig.TileCellSize; @@ -528,19 +536,19 @@ private void FullHorizontalAisleRight(AutoTileConfig config, Rect2 rect, RoomDoorInfo doorInfo = null) { //右 - ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(rect.Size.X, 1), new Vector2(1, rect.Size.Y - 2)); + ClearRect(MapLayer.AutoTopLayer, rect.Position + new Vector2(rect.Size.X, 1), new Vector2(1, rect.Size.Y - 2)); if (doorInfo == null) { - FillRect(GameConfig.AisleFloorMapLayer, config.Floor, rect.Position + new Vector2(rect.Size.X, 1), new Vector2(1, rect.Size.Y - 2)); + FillRect(MapLayer.AutoAisleFloorLayer, config.Floor, rect.Position + new Vector2(rect.Size.X, 1), new Vector2(1, rect.Size.Y - 2)); } else { - ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(rect.Size.X - 1, -1), new Vector2(2, 4)); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Vertical_Right, rect.Position + new Vector2(rect.Size.X, 0), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Out_RB, 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); + ClearRect(MapLayer.AutoTopLayer, rect.Position + new Vector2(rect.Size.X - 1, -1), new Vector2(2, 4)); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Right, rect.Position + new Vector2(rect.Size.X, 0), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Out_RB, rect.Position + new Vector2(rect.Size.X, -1), Vector2.One); + FillRect(MapLayer.AutoTopLayer, 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)); + FillRect(MapLayer.AutoFloorLayer, config.Floor, rect.Position + new Vector2(rect.Size.X, 1), new Vector2(1, rect.Size.Y - 2)); //生成门的导航区域 var x = rect.Position.X * GameConfig.TileCellSize; var y = rect.Position.Y * GameConfig.TileCellSize; @@ -563,19 +571,19 @@ private void FullVerticalAisleUp(AutoTileConfig config, Rect2 rect, RoomDoorInfo doorInfo = null) { //上 - ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.X - 2, 1)); + ClearRect(MapLayer.AutoTopLayer, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.X - 2, 1)); if (doorInfo == null) { - FillRect(GameConfig.AisleFloorMapLayer, config.Floor, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.X - 2, 1)); + FillRect(MapLayer.AutoAisleFloorLayer, config.Floor, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.X - 2, 1)); } else { - ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(1, 0), new Vector2(2, 2)); + ClearRect(MapLayer.AutoTopLayer, rect.Position + new Vector2(1, 0), new Vector2(2, 2)); - 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(MapLayer.AutoTopLayer, config.Wall_Out_RT, rect.Position + new Vector2(0, -1), Vector2.One); + FillRect(MapLayer.AutoTopLayer, 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)); + FillRect(MapLayer.AutoFloorLayer, config.Floor, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.X - 2, 1)); //生成门的导航区域 var x = rect.Position.X * GameConfig.TileCellSize; var y = rect.Position.Y * GameConfig.TileCellSize; @@ -598,22 +606,22 @@ private void FullVerticalAisleDown(AutoTileConfig config, Rect2 rect, RoomDoorInfo doorInfo = null) { //下 - ClearRect(GameConfig.MiddleMapLayer, rect.Position + new Vector2(1, rect.Size.Y), new Vector2(rect.Size.X - 2, 1)); + ClearRect(MapLayer.AutoMiddleLayer, rect.Position + new Vector2(1, rect.Size.Y), new Vector2(rect.Size.X - 2, 1)); if (doorInfo == null) { - FillRect(GameConfig.AisleFloorMapLayer, config.Floor, rect.Position + new Vector2(1, rect.Size.Y), new Vector2(rect.Size.X - 2, 1)); + FillRect(MapLayer.AutoAisleFloorLayer, config.Floor, rect.Position + new Vector2(1, rect.Size.Y), new Vector2(rect.Size.X - 2, 1)); } else { - ClearRect(GameConfig.TopMapLayer, rect.Position + new Vector2(1, rect.Size.Y - 2), new Vector2(2, 2)); - ClearRect(GameConfig.MiddleMapLayer, rect.Position + new Vector2(0, rect.Size.Y - 1), new Vector2(4, 2)); + ClearRect(MapLayer.AutoTopLayer, rect.Position + new Vector2(1, rect.Size.Y - 2), new Vector2(2, 2)); + ClearRect(MapLayer.AutoMiddleLayer, rect.Position + new Vector2(0, rect.Size.Y - 1), new Vector2(4, 2)); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Out_RB, rect.Position + new Vector2(0, rect.Size.Y - 1), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Vertical_Right, rect.Position + new Vector2(0, rect.Size.Y), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Out_LB, rect.Position + new Vector2(rect.Size.X - 1, rect.Size.Y - 1), Vector2.One); - FillRect(GameConfig.MiddleMapLayer, config.Wall_Vertical_Left, rect.Position + new Vector2(rect.Size.X - 1, rect.Size.Y), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Out_RB, rect.Position + new Vector2(0, rect.Size.Y - 1), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Right, rect.Position + new Vector2(0, rect.Size.Y), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Out_LB, rect.Position + new Vector2(rect.Size.X - 1, rect.Size.Y - 1), Vector2.One); + FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_Left, rect.Position + new Vector2(rect.Size.X - 1, 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)); + FillRect(MapLayer.AutoFloorLayer, config.Floor, rect.Position + new Vector2(1, rect.Size.Y), new Vector2(rect.Size.X - 2, 1)); //生成门的导航区域 var x = rect.Position.X * GameConfig.TileCellSize; var y = rect.Position.Y * GameConfig.TileCellSize; diff --git a/DungeonShooting_Godot/src/framework/map/fog/FogMask.cs b/DungeonShooting_Godot/src/framework/map/fog/FogMask.cs index 1052dd7..86fc1b6 100644 --- a/DungeonShooting_Godot/src/framework/map/fog/FogMask.cs +++ b/DungeonShooting_Godot/src/framework/map/fog/FogMask.cs @@ -123,7 +123,7 @@ { var pos = new Vector2I(i + x, j + y); //说明是外层墙壁 - if (tileMap.GetCellAtlasCoords(GameConfig.TopMapLayer, pos) == wallCoords) + if (tileMap.GetCellAtlasCoords(MapLayer.AutoTopLayer, pos) == wallCoords) { var left = IsEmptyCell(tileMap, new Vector2I(pos.X - 1, pos.Y)); var right = IsEmptyCell(tileMap, new Vector2I(pos.X + 1, pos.Y)); @@ -223,25 +223,25 @@ private bool IsEmptyCell(TileMap tileMap, Vector2I pos) { - return tileMap.GetCellSourceId(GameConfig.TopMapLayer, pos) == -1 && - tileMap.GetCellSourceId(GameConfig.MiddleMapLayer, pos) == -1; + return tileMap.GetCellSourceId(MapLayer.AutoTopLayer, pos) == -1 && + tileMap.GetCellSourceId(MapLayer.AutoMiddleLayer, pos) == -1; } //判断是否是墙壁 private bool IsNotWallCell(TileMap tileMap, Vector2I pos, Vector2I wallCoord) { - return tileMap.GetCellAtlasCoords(GameConfig.TopMapLayer, pos) != wallCoord && - tileMap.GetCellAtlasCoords(GameConfig.MiddleMapLayer, pos) != wallCoord && - (tileMap.GetCellSourceId(GameConfig.TopMapLayer, pos) != -1 || - tileMap.GetCellSourceId(GameConfig.MiddleMapLayer, pos) != -1); + return tileMap.GetCellAtlasCoords(MapLayer.AutoTopLayer, pos) != wallCoord && + tileMap.GetCellAtlasCoords(MapLayer.AutoMiddleLayer, pos) != wallCoord && + (tileMap.GetCellSourceId(MapLayer.AutoTopLayer, pos) != -1 || + tileMap.GetCellSourceId(MapLayer.AutoMiddleLayer, pos) != -1); } //判断是否是任意类型的图块 private bool IsAnyCell(TileMap tileMap, Vector2I pos) { - return tileMap.GetCellSourceId(GameConfig.FloorMapLayer, pos) != -1 || - tileMap.GetCellSourceId(GameConfig.MiddleMapLayer, pos) != -1 || - tileMap.GetCellSourceId(GameConfig.TopMapLayer, pos) != -1 || - tileMap.GetCellSourceId(GameConfig.AisleFloorMapLayer, pos) != -1; + return tileMap.GetCellSourceId(MapLayer.AutoFloorLayer, pos) != -1 || + tileMap.GetCellSourceId(MapLayer.AutoMiddleLayer, pos) != -1 || + tileMap.GetCellSourceId(MapLayer.AutoTopLayer, pos) != -1 || + tileMap.GetCellSourceId(MapLayer.AutoAisleFloorLayer, pos) != -1; } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index 21cc943..406b960 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -167,6 +167,7 @@ World.QueueFree(); } World = ResourceManager.LoadAndInstantiate(ResourcePath.scene_World_tscn); + World.InitLayer(); SceneRoot.AddChild(World); return World; } diff --git a/DungeonShooting_Godot/src/game/GameConfig.cs b/DungeonShooting_Godot/src/game/GameConfig.cs index 904556d..f69bc4e 100644 --- a/DungeonShooting_Godot/src/game/GameConfig.cs +++ b/DungeonShooting_Godot/src/game/GameConfig.cs @@ -58,36 +58,6 @@ /// ui代码根路径 /// public const string UiCodeDir = "src/game/ui/"; - - /// - /// TileMap 地板的层级 - /// - public const int FloorMapLayer = 0; - /// - /// TileMap 中层的层级 - /// - public const int MiddleMapLayer = 1; - /// - /// TileMap 上层的层级 - /// - public const int TopMapLayer = 2; - /// - /// 连接房间的过道的地板层级 - /// - public const int AisleFloorMapLayer = 3; - - /// - /// TileMap 地板的 Zindex - /// - public const int FloorMapZIndex = -10; - /// - /// TileMap 中层的 Zindex - /// - public const int MiddleMapZIndex = 0; - /// - /// TileMap 上层的 Zindex - /// - public const int TopMapZindex = 10; /// /// 配置层级的自定义数据名称 diff --git a/DungeonShooting_Godot/src/game/data/property/MapLayer.cs b/DungeonShooting_Godot/src/game/data/property/MapLayer.cs index 472d358..f9995a5 100644 --- a/DungeonShooting_Godot/src/game/data/property/MapLayer.cs +++ b/DungeonShooting_Godot/src/game/data/property/MapLayer.cs @@ -38,7 +38,12 @@ /// public const int CustomTopLayer = AutoTopLayer + 1; /// - /// 标记数据层 + /// 自动图块过道中的地板层, 该层只会出现在 World 场景中的 TileMap /// - public const int MarkLayer = 999; + public const int AutoAisleFloorLayer = CustomTopLayer + 1; + + /// + /// 标记数据层, 特殊层, 不会出现在 TileMap 中 + /// + public const int MarkLayer = 9999; } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs b/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs index d7a21cc..58624c4 100644 --- a/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs +++ b/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs @@ -121,19 +121,19 @@ int[] data; if (terrainInfo.M.TryGetValue(0, out data)) { - Wall_Vertical_Single = new TileCellData(sourceId, terrainInfo.GetPosition(data), 0, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); + Wall_Vertical_Single = new TileCellData(sourceId, terrainInfo.GetPosition(data), 0, TileSetTerrainInfo.MiddleLayerType, MapLayer.AutoMiddleLayer); } if (terrainInfo.M.TryGetValue(1, out data)) { - Wall_Vertical_Left= new TileCellData(sourceId, terrainInfo.GetPosition(data), 1, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); + Wall_Vertical_Left= new TileCellData(sourceId, terrainInfo.GetPosition(data), 1, TileSetTerrainInfo.MiddleLayerType, MapLayer.AutoMiddleLayer); } if (terrainInfo.M.TryGetValue(2, out data)) { - Wall_Vertical_Center= new TileCellData(sourceId, terrainInfo.GetPosition(data), 2, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); + Wall_Vertical_Center= new TileCellData(sourceId, terrainInfo.GetPosition(data), 2, TileSetTerrainInfo.MiddleLayerType, MapLayer.AutoMiddleLayer); } if (terrainInfo.M.TryGetValue(3, out data)) { - Wall_Vertical_Right= new TileCellData(sourceId, terrainInfo.GetPosition(data), 3, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); + Wall_Vertical_Right= new TileCellData(sourceId, terrainInfo.GetPosition(data), 3, TileSetTerrainInfo.MiddleLayerType, MapLayer.AutoMiddleLayer); } } @@ -141,7 +141,7 @@ { if (terrainInfo.F.TryGetValue(0, out var data)) { - Floor = new TileCellData(sourceId, terrainInfo.GetPosition(data), 0, TileSetTerrainInfo.FloorLayerType, GameConfig.FloorMapLayer); + Floor = new TileCellData(sourceId, terrainInfo.GetPosition(data), 0, TileSetTerrainInfo.FloorLayerType, MapLayer.AutoFloorLayer); } } @@ -172,7 +172,7 @@ return tile.DefaultLayer; } - return GameConfig.FloorMapLayer; + return MapLayer.AutoFloorLayer; } public TileCellData GetCellData(Vector2I atlasCoords) @@ -187,185 +187,185 @@ { //第一列 case TerrainPeering.Center | TerrainPeering.Bottom: - Auto_000_010_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_010_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Center | TerrainPeering.Bottom: - Auto_010_010_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_010_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Center: - Auto_010_010_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_010_010_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; case TerrainPeering.Center: - Auto_000_010_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_000_010_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; //第二列 case TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: - Auto_000_011_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_011_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: - Auto_010_011_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_011_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Center | TerrainPeering.Right: - Auto_010_011_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_010_011_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; case TerrainPeering.Center | TerrainPeering.Right: - Auto_000_011_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_000_011_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; //第三列 case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: - Auto_000_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: - Auto_010_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right: - Auto_010_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_010_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right: - Auto_000_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_000_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; //第四列 case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Bottom: - Auto_000_110_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_110_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Bottom: - Auto_010_110_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_110_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center: - Auto_010_110_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_010_110_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; case TerrainPeering.Left | TerrainPeering.Center: - Auto_000_110_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_000_110_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; //第五列 case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: - Auto_110_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_110_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_010_011_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_011_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: - Auto_011_011_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_011_011_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom: - Auto_010_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; //第六列 case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_000_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_011_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_011_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_111_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_111_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right: - Auto_011_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_011_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; //第七列 case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom: - Auto_000_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_110_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_110_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom: - Auto_111_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_111_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right: - Auto_110_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_110_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; //第八列 case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: - Auto_011_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_011_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.LeftBottom | TerrainPeering.Bottom: - Auto_010_110_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_110_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Bottom: - Auto_110_110_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_110_110_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_010_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; //第九列 case TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_000_011_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_011_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_011_011_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_011_011_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_011_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_011_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Center | TerrainPeering.Right: - Auto_011_011_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_011_011_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; //第十列 case TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_010_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_010_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_110_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_110_111_011 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_111_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_111_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right: - Auto_111_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_111_111_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; //第十一列 case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom | TerrainPeering.RightBottom: - Auto_000_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_111_111 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom: - Auto_011_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_011_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.RightTop | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.Bottom: - Auto_111_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_111_111_010 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; //第十二列 case TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.LeftBottom | TerrainPeering.Bottom: - Auto_000_110_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_000_110_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.Right | TerrainPeering.LeftBottom | TerrainPeering.Bottom: - Auto_110_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_110_111_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center | TerrainPeering.LeftBottom | TerrainPeering.Bottom: - Auto_110_110_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.TopMapLayer); + Auto_110_110_110 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoTopLayer); break; case TerrainPeering.LeftTop | TerrainPeering.Top | TerrainPeering.Left | TerrainPeering.Center: - Auto_110_110_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, GameConfig.MiddleMapLayer); + Auto_110_110_000 = new TileCellData(sourceId, pos, peeringValue, TileSetTerrainInfo.TerrainLayerType, MapLayer.AutoMiddleLayer); break; default: diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index 3f2de43..2721a55 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -234,7 +234,7 @@ //yield return _dungeonTileMap.AddOutlineTile(AutoTileConfig.WALL_BLOCK); //生成寻路网格, 这一步操作只生成过道的导航 - _dungeonTileMap.GenerateNavigationPolygon(GameConfig.AisleFloorMapLayer); + _dungeonTileMap.GenerateNavigationPolygon(MapLayer.AutoAisleFloorLayer); yield return 0; //将导航网格绑定到 DoorInfo 上 BindAisleNavigation(StartRoomInfo, _dungeonTileMap.GetPolygonData()); @@ -417,22 +417,22 @@ case DoorDirection.E: door = ActivityObject.Create(ActivityObject.Ids.Id_other_door_e); door.Position = (doorInfo.OriginPosition + new Vector2(0.5f, 2)) * GameConfig.TileCellSize; - door.ZIndex = GameConfig.TopMapLayer; + door.ZIndex = MapLayer.AutoTopLayer; break; case DoorDirection.W: door = ActivityObject.Create(ActivityObject.Ids.Id_other_door_w); door.Position = (doorInfo.OriginPosition + new Vector2(-0.5f, 2)) * GameConfig.TileCellSize; - door.ZIndex = GameConfig.TopMapLayer; + door.ZIndex = MapLayer.AutoTopLayer; break; case DoorDirection.S: door = ActivityObject.Create(ActivityObject.Ids.Id_other_door_s); door.Position = (doorInfo.OriginPosition + new Vector2(2f, 1.5f)) * GameConfig.TileCellSize; - door.ZIndex = GameConfig.TopMapLayer; + door.ZIndex = MapLayer.AutoTopLayer; break; case DoorDirection.N: door = ActivityObject.Create(ActivityObject.Ids.Id_other_door_n); door.Position = (doorInfo.OriginPosition + new Vector2(2f, -0.5f)) * GameConfig.TileCellSize; - door.ZIndex = GameConfig.MiddleMapLayer; + door.ZIndex = MapLayer.AutoMiddleLayer; break; default: return; diff --git a/DungeonShooting_Godot/src/game/room/RoomDoor.cs b/DungeonShooting_Godot/src/game/room/RoomDoor.cs index 4d15411..8059b62 100644 --- a/DungeonShooting_Godot/src/game/room/RoomDoor.cs +++ b/DungeonShooting_Godot/src/game/room/RoomDoor.cs @@ -89,26 +89,26 @@ switch (Direction) { case DoorDirection.E: - ZIndex = GameConfig.TopMapLayer; + ZIndex = MapLayer.AutoTopLayer; if (_animatedDown != null) { - _animatedDown.ZIndex = GameConfig.TopMapLayer; + _animatedDown.ZIndex = MapLayer.AutoTopLayer; } break; case DoorDirection.W: - ZIndex = GameConfig.TopMapLayer; + ZIndex = MapLayer.AutoTopLayer; if (_animatedDown != null) { - _animatedDown.ZIndex = GameConfig.TopMapLayer; + _animatedDown.ZIndex = MapLayer.AutoTopLayer; } break; case DoorDirection.S: - ZIndex = GameConfig.TopMapLayer; + ZIndex = MapLayer.AutoTopLayer; break; case DoorDirection.N: - ZIndex = GameConfig.MiddleMapLayer; + ZIndex = MapLayer.AutoMiddleLayer; break; } } @@ -133,32 +133,32 @@ _door.Navigation.CloseNavigationNode.Visible = false; } //调整门的层级 - //ZIndex = GameConfig.FloorMapLayer; + //ZIndex = MapLayer.AutoFloorLayer; //调整门的层级 switch (Direction) { case DoorDirection.E: - ZIndex = GameConfig.MiddleMapLayer; + ZIndex = MapLayer.AutoMiddleLayer; if (_animatedDown != null) { - _animatedDown.ZIndex = GameConfig.TopMapLayer; + _animatedDown.ZIndex = MapLayer.AutoTopLayer; } break; case DoorDirection.W: - ZIndex = GameConfig.MiddleMapLayer; + ZIndex = MapLayer.AutoMiddleLayer; if (_animatedDown != null) { - _animatedDown.ZIndex = GameConfig.TopMapLayer; + _animatedDown.ZIndex = MapLayer.AutoTopLayer; } break; case DoorDirection.S: - ZIndex = GameConfig.TopMapLayer; + ZIndex = MapLayer.AutoTopLayer; break; case DoorDirection.N: - ZIndex = GameConfig.MiddleMapLayer; + ZIndex = MapLayer.AutoMiddleLayer; break; } } diff --git a/DungeonShooting_Godot/src/game/room/World.cs b/DungeonShooting_Godot/src/game/room/World.cs index 75f8634..8c7bef9 100644 --- a/DungeonShooting_Godot/src/game/room/World.cs +++ b/DungeonShooting_Godot/src/game/room/World.cs @@ -86,6 +86,46 @@ } /// + /// 初始化 TileMap 中的层级 + /// + public void InitLayer() + { + TileRoot.AddLayer(MapLayer.AutoFloorLayer); + TileRoot.SetLayerZIndex(MapLayer.AutoFloorLayer, -10); + TileRoot.SetLayerNavigationEnabled(MapLayer.AutoFloorLayer, false); + TileRoot.AddLayer(MapLayer.CustomFloorLayer1); + TileRoot.SetLayerZIndex(MapLayer.CustomFloorLayer1, -10); + TileRoot.SetLayerNavigationEnabled(MapLayer.CustomFloorLayer1, false); + TileRoot.AddLayer(MapLayer.CustomFloorLayer2); + TileRoot.SetLayerZIndex(MapLayer.CustomFloorLayer2, -10); + TileRoot.SetLayerNavigationEnabled(MapLayer.CustomFloorLayer2, false); + TileRoot.AddLayer(MapLayer.CustomFloorLayer3); + TileRoot.SetLayerZIndex(MapLayer.CustomFloorLayer3, -10); + TileRoot.SetLayerNavigationEnabled(MapLayer.CustomFloorLayer3, false); + TileRoot.AddLayer(MapLayer.AutoMiddleLayer); + TileRoot.SetLayerZIndex(MapLayer.AutoMiddleLayer, 0); + TileRoot.SetLayerNavigationEnabled(MapLayer.AutoMiddleLayer, false); + TileRoot.SetLayerYSortEnabled(MapLayer.AutoMiddleLayer, true); + TileRoot.AddLayer(MapLayer.CustomMiddleLayer1); + TileRoot.SetLayerZIndex(MapLayer.CustomMiddleLayer1, 0); + TileRoot.SetLayerNavigationEnabled(MapLayer.CustomMiddleLayer1, false); + TileRoot.SetLayerYSortEnabled(MapLayer.CustomMiddleLayer1, true); + TileRoot.AddLayer(MapLayer.CustomMiddleLayer2); + TileRoot.SetLayerZIndex(MapLayer.CustomMiddleLayer2, 0); + TileRoot.SetLayerNavigationEnabled(MapLayer.CustomMiddleLayer2, false); + TileRoot.SetLayerYSortEnabled(MapLayer.CustomMiddleLayer2, true); + TileRoot.AddLayer(MapLayer.AutoTopLayer); + TileRoot.SetLayerZIndex(MapLayer.AutoTopLayer, 10); + TileRoot.SetLayerNavigationEnabled(MapLayer.AutoTopLayer, false); + TileRoot.AddLayer(MapLayer.CustomTopLayer); + TileRoot.SetLayerZIndex(MapLayer.CustomTopLayer, 10); + TileRoot.SetLayerNavigationEnabled(MapLayer.CustomTopLayer, false); + TileRoot.AddLayer(MapLayer.AutoAisleFloorLayer); + TileRoot.SetLayerZIndex(MapLayer.AutoAisleFloorLayer, -10); + TileRoot.SetLayerNavigationEnabled(MapLayer.AutoAisleFloorLayer, false); + } + + /// /// 获取指定层级根节点 /// public Node2D GetRoomLayer(RoomLayerEnum layerEnum) diff --git a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs index 1434c94..fdb0fed 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs @@ -162,6 +162,8 @@ //笔刷偏移, 单位: 格 private Vector2I _brushOffset = Vector2I.Zero; + //淡化其它层级 + private bool _desaltOtherLayer = false; //--------------------------------------- 变动过的数据 --------------------------------------- @@ -460,6 +462,15 @@ { CurrLayer = layerData; MapEditorToolsPanel.S_CurrLayer.Instance.Text = "当前图层:" + layerData.Title; + SetLayerModulate(MapLayer.AutoFloorLayer, _GetEditorLayerModulate(MapLayer.AutoFloorLayer)); + SetLayerModulate(MapLayer.AutoMiddleLayer, _GetEditorLayerModulate(MapLayer.AutoMiddleLayer)); + SetLayerModulate(MapLayer.AutoTopLayer, _GetEditorLayerModulate(MapLayer.AutoTopLayer)); + SetLayerModulate(MapLayer.CustomFloorLayer1, _GetEditorLayerModulate(MapLayer.CustomFloorLayer1)); + SetLayerModulate(MapLayer.CustomFloorLayer2, _GetEditorLayerModulate(MapLayer.CustomFloorLayer2)); + SetLayerModulate(MapLayer.CustomFloorLayer3, _GetEditorLayerModulate(MapLayer.CustomFloorLayer3)); + SetLayerModulate(MapLayer.CustomMiddleLayer1, _GetEditorLayerModulate(MapLayer.CustomMiddleLayer1)); + SetLayerModulate(MapLayer.CustomMiddleLayer2, _GetEditorLayerModulate(MapLayer.CustomMiddleLayer2)); + SetLayerModulate(MapLayer.CustomTopLayer, _GetEditorLayerModulate(MapLayer.CustomTopLayer)); } /// @@ -511,6 +522,12 @@ CurrBrushTexture = texture; } + public void SetDesaltOtherLayer(bool flag) + { + _desaltOtherLayer = flag; + SetCurrentLayer(CurrLayer); + } + /// /// 尝试运行检查, 如果已经运行过了, 则没有效果 /// @@ -731,6 +748,8 @@ _initLayer = true; //初始化层级数据 + AddLayer(MapLayer.AutoFloorLayer); + SetLayerZIndex(MapLayer.AutoFloorLayer, MapLayer.AutoFloorLayer); AddLayer(MapLayer.CustomFloorLayer1); SetLayerZIndex(MapLayer.CustomFloorLayer1, MapLayer.CustomFloorLayer1); AddLayer(MapLayer.CustomFloorLayer2); @@ -1079,11 +1098,11 @@ { var atlasCoords = GetCellAtlasCoords(MapLayer.AutoFloorLayer, pos); var layer = _autoTileConfig.GetLayer(atlasCoords); - if (layer == GameConfig.MiddleMapLayer) + if (layer == MapLayer.AutoMiddleLayer) { layer = MapLayer.AutoMiddleLayer; } - else if (layer == GameConfig.TopMapLayer) + else if (layer == MapLayer.AutoTopLayer) { layer = MapLayer.AutoTopLayer; } @@ -1465,6 +1484,16 @@ SetLayerEnabled(MapLayer.CustomMiddleLayer2, true); SetLayerEnabled(MapLayer.AutoTopLayer, true); SetLayerEnabled(MapLayer.CustomTopLayer, true); + + SetLayerModulate(MapLayer.AutoFloorLayer, Colors.White); + SetLayerModulate(MapLayer.CustomFloorLayer1, Colors.White); + SetLayerModulate(MapLayer.CustomFloorLayer2, Colors.White); + SetLayerModulate(MapLayer.CustomFloorLayer3, Colors.White); + SetLayerModulate(MapLayer.AutoMiddleLayer, Colors.White); + SetLayerModulate(MapLayer.CustomMiddleLayer1, Colors.White); + SetLayerModulate(MapLayer.CustomMiddleLayer2, Colors.White); + SetLayerModulate(MapLayer.AutoTopLayer, Colors.White); + SetLayerModulate(MapLayer.CustomTopLayer, Colors.White); } private void OnFramePostDraw() @@ -1492,6 +1521,7 @@ SetLayerEnabled(MapLayer.CustomMiddleLayer1, _tempCustomMiddleLayer1); SetLayerEnabled(MapLayer.CustomMiddleLayer2, _tempCustomMiddleLayer2); SetLayerEnabled(MapLayer.CustomTopLayer, _tempCustomTopLayer); + SetCurrentLayer(CurrLayer); //保存预览图 var subViewport = MapEditorPanel.S_SubViewport.Instance; @@ -1531,4 +1561,14 @@ _polygonData[i] = v2Array; } } + + private Color _GetEditorLayerModulate(int layer) + { + if (!_desaltOtherLayer) + { + return Colors.White; + } + + return layer == CurrLayer.Layer ? Colors.White : new Color(1, 1, 1, 0.3f); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/MapEditorMapLayer.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/MapEditorMapLayer.cs index f8933d8..dabbdcc 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/MapEditorMapLayer.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/MapEditorMapLayer.cs @@ -29,12 +29,56 @@ } /// - /// 类型: , 路径: MapEditorMapLayer.VBoxContainer.LayerLabel + /// 类型: , 路径: MapEditorMapLayer.VBoxContainer.HBoxContainer.Label /// - public class LayerLabel : UiNode + public class Label : UiNode { - public LayerLabel(MapEditorMapLayerPanel uiPanel, Godot.Label node) : base(uiPanel, node) { } - public override LayerLabel Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + public Label(MapEditorMapLayerPanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Label Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: MapEditorMapLayer.VBoxContainer.HBoxContainer.CheckButton + /// + public class CheckButton : UiNode + { + public CheckButton(MapEditorMapLayerPanel uiPanel, Godot.CheckButton node) : base(uiPanel, node) { } + public override CheckButton Clone() => new (UiPanel, (Godot.CheckButton)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: MapEditorMapLayer.VBoxContainer.HBoxContainer + /// + public class HBoxContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapLayer.VBoxContainer.Label + /// + public Label L_Label + { + get + { + if (_L_Label == null) _L_Label = new Label(UiPanel, Instance.GetNode("Label")); + return _L_Label; + } + } + private Label _L_Label; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapLayer.VBoxContainer.CheckButton + /// + public CheckButton L_CheckButton + { + get + { + if (_L_CheckButton == null) _L_CheckButton = new CheckButton(UiPanel, Instance.GetNode("CheckButton")); + return _L_CheckButton; + } + } + private CheckButton _L_CheckButton; + + public HBoxContainer(MapEditorMapLayerPanel uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); } /// @@ -118,17 +162,17 @@ public class VBoxContainer : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapLayer.LayerLabel + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapLayer.HBoxContainer /// - public LayerLabel L_LayerLabel + public HBoxContainer L_HBoxContainer { get { - if (_L_LayerLabel == null) _L_LayerLabel = new LayerLabel(UiPanel, Instance.GetNode("LayerLabel")); - return _L_LayerLabel; + if (_L_HBoxContainer == null) _L_HBoxContainer = new HBoxContainer(UiPanel, Instance.GetNode("HBoxContainer")); + return _L_HBoxContainer; } } - private LayerLabel _L_LayerLabel; + private HBoxContainer _L_HBoxContainer; /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapLayer.ScrollContainer @@ -149,9 +193,19 @@ /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapLayer.VBoxContainer.LayerLabel + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapLayer.VBoxContainer.HBoxContainer.Label /// - public LayerLabel S_LayerLabel => L_VBoxContainer.L_LayerLabel; + public Label S_Label => L_VBoxContainer.L_HBoxContainer.L_Label; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapLayer.VBoxContainer.HBoxContainer.CheckButton + /// + public CheckButton S_CheckButton => L_VBoxContainer.L_HBoxContainer.L_CheckButton; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapLayer.VBoxContainer.HBoxContainer + /// + public HBoxContainer S_HBoxContainer => L_VBoxContainer.L_HBoxContainer; /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapLayer.VBoxContainer.ScrollContainer.LayerButton.SelectTexture diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/MapEditorMapLayerPanel.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/MapEditorMapLayerPanel.cs index a73691e..7fb981e 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/MapEditorMapLayerPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/MapEditorMapLayerPanel.cs @@ -33,5 +33,12 @@ _grid.Add(new TileMapLayerData("顶层", MapLayer.CustomTopLayer, false)); _grid.Add(new TileMapLayerData("标记数据层", MapLayer.MarkLayer, true)); _grid.SelectIndex = 0; + + S_CheckButton.Instance.Toggled += OnToggled; + } + + private void OnToggled(bool toggledon) + { + EditorTileMap.SetDesaltOtherLayer(toggledon); } }