diff --git a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json index e84e164..e6bcbed 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json @@ -60,7 +60,7 @@ ], "EventList": [ { - "ErrorType": 0, + "ErrorType": 2, "Path": "resource/map/tileMaps/Test1/event/\u6D4B\u8BD5\u623F\u95F4" } ], diff --git "a/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/Preview.png" "b/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/Preview.png" index 1f8c70e..d2ad303 100644 --- "a/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/Preview.png" +++ "b/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/Preview.png" Binary files differ diff --git "a/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/RoomInfo.json" "b/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/RoomInfo.json" index 21c8432..3e904a7 100644 --- "a/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/RoomInfo.json" +++ "b/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/RoomInfo.json" @@ -1 +1 @@ -{"Position":{"X":-19,"Y":-10},"Size":{"X":27,"Y":27},"DoorAreaInfos":[],"GroupName":"Test1","RoomType":64,"RoomName":"\u6D4B\u8BD5\u623F\u95F4","Weight":100,"Remark":""} \ No newline at end of file +{"Position":{"X":-20,"Y":-11},"Size":{"X":29,"Y":29},"DoorAreaInfos":[],"GroupName":"Test1","RoomType":64,"RoomName":"\u6D4B\u8BD5\u623F\u95F4","Weight":100,"Remark":""} \ No newline at end of file diff --git "a/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/TileInfo.json" "b/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/TileInfo.json" index 5f99a1a..e33c38d 100644 --- "a/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/TileInfo.json" +++ "b/DungeonShooting_Godot/resource/map/tileMaps/Test1/event/\346\265\213\350\257\225\346\210\277\351\227\264/TileInfo.json" @@ -1 +1 @@ -{"NavigationVertices":[{"X":-26,"Y":-26},{"X":-26,"Y":-58},{"X":90,"Y":-58},{"X":90,"Y":36},{"X":42,"Y":36},{"X":42,"Y":150},{"X":22,"Y":150},{"X":22,"Y":36},{"X":-26,"Y":-12},{"X":-26,"Y":36},{"X":-166,"Y":-26},{"X":-166,"Y":-12},{"X":-166,"Y":52},{"X":-182,"Y":52},{"X":-26,"Y":166},{"X":-26,"Y":150},{"X":90,"Y":150},{"X":90,"Y":244},{"X":-26,"Y":244},{"X":-26,"Y":180},{"X":-182,"Y":166},{"X":-202,"Y":180},{"X":-202,"Y":52},{"X":-266,"Y":52},{"X":-266,"Y":-106},{"X":-166,"Y":-106}],"NavigationPolygon":[[0,1,2,3,4],[4,5,6,7],[0,4,7,8],[7,9,8],[10,0,8,11],[11,12,13],[14,15,6],[5,16,17,18,19],[6,5,19,14],[20,14,19,21],[20,21,22,13],[22,23,24,25,10],[22,10,11,13]],"Floor":[-2,-4,0,3,-1,-4,0,3,-1,-3,0,3,0,-2,0,3,1,-2,0,3,1,-1,0,3,2,-1,0,3,3,-1,0,3,3,0,0,3,4,0,0,3,5,0,0,3,5,1,0,3,-2,-3,0,3,-2,-2,0,3,-2,-1,0,3,-2,0,0,3,-1,-2,0,3,-1,-1,0,3,-1,0,0,3,0,-4,0,3,0,-3,0,3,0,-1,0,3,0,0,0,3,1,-4,0,3,1,-3,0,3,1,0,0,3,2,-4,0,3,2,-3,0,3,2,-2,0,3,2,0,0,3,3,-4,0,3,3,-3,0,3,3,-2,0,3,4,-4,0,3,4,-3,0,3,4,-2,0,3,4,-1,0,3,5,-4,0,3,5,-3,0,3,5,-2,0,3,5,-1,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,4,1,0,3,1,2,0,3,2,2,0,3,-2,9,0,3,-2,10,0,3,-2,11,0,3,-2,12,0,3,-2,13,0,3,-2,14,0,3,-1,9,0,3,-1,10,0,3,-1,11,0,3,-1,12,0,3,-1,13,0,3,-1,14,0,3,0,9,0,3,0,10,0,3,0,11,0,3,0,12,0,3,0,13,0,3,0,14,0,3,1,9,0,3,1,10,0,3,1,11,0,3,1,12,0,3,1,13,0,3,1,14,0,3,2,9,0,3,2,10,0,3,2,11,0,3,2,12,0,3,2,13,0,3,2,14,0,3,3,9,0,3,3,10,0,3,3,11,0,3,3,12,0,3,3,13,0,3,3,14,0,3,4,9,0,3,4,10,0,3,4,11,0,3,4,12,0,3,4,13,0,3,4,14,0,3,5,9,0,3,5,10,0,3,5,11,0,3,5,12,0,3,5,13,0,3,5,14,0,3,1,3,0,3,1,4,0,3,1,5,0,3,1,6,0,3,1,7,0,3,1,8,0,3,2,3,0,3,2,4,0,3,2,5,0,3,2,6,0,3,2,7,0,3,2,8,0,3,-17,-7,0,3,-17,-6,0,3,-16,-6,0,3,-16,-5,0,3,-15,-5,0,3,-15,-4,0,3,-14,-3,0,3,-14,-2,0,3,-13,-2,0,3,-13,-1,0,3,-12,-1,0,3,-12,0,0,3,-11,0,0,3,-11,1,0,3,-17,-5,0,3,-17,-4,0,3,-17,-3,0,3,-17,-2,0,3,-17,-1,0,3,-17,0,0,3,-17,1,0,3,-17,2,0,3,-16,-7,0,3,-16,-4,0,3,-16,-3,0,3,-16,-2,0,3,-16,-1,0,3,-16,0,0,3,-16,1,0,3,-16,2,0,3,-15,-7,0,3,-15,-6,0,3,-15,-3,0,3,-15,-2,0,3,-15,-1,0,3,-15,0,0,3,-15,1,0,3,-15,2,0,3,-14,-7,0,3,-14,-6,0,3,-14,-5,0,3,-14,-4,0,3,-14,-1,0,3,-14,0,0,3,-14,1,0,3,-14,2,0,3,-13,-7,0,3,-13,-6,0,3,-13,-5,0,3,-13,-4,0,3,-13,-3,0,3,-13,0,0,3,-13,1,0,3,-13,2,0,3,-12,-7,0,3,-12,-6,0,3,-12,-5,0,3,-12,-4,0,3,-12,-3,0,3,-12,-2,0,3,-12,1,0,3,-12,2,0,3,-11,-7,0,3,-11,-6,0,3,-11,-5,0,3,-11,-4,0,3,-11,-3,0,3,-11,-2,0,3,-11,-1,0,3,-11,2,0,3,-10,-2,0,3,-9,-2,0,3,-8,-2,0,3,-7,-2,0,3,-6,-2,0,3,-5,-2,0,3,-4,-2,0,3,-3,-2,0,3,-13,3,0,3,-13,4,0,3,-13,5,0,3,-13,6,0,3,-13,7,0,3,-13,8,0,3,-13,9,0,3,-13,10,0,3,-12,3,0,3,-12,4,0,3,-12,5,0,3,-12,6,0,3,-12,7,0,3,-12,8,0,3,-12,9,0,3,-12,10,0,3,-11,10,0,3,-10,10,0,3,-9,10,0,3,-8,10,0,3,-7,10,0,3,-6,10,0,3,-5,10,0,3,-4,10,0,3,-3,10,0,3],"Middle":[-17,-10,63,1,-17,-9,2,2,-17,-8,6,2,-16,-10,63,1,-16,-9,2,2,-16,-8,6,2,-15,-10,63,1,-15,-9,2,2,-15,-8,6,2,-14,-10,63,1,-14,-9,2,2,-14,-8,6,2,-13,-10,63,1,-13,-9,2,2,-13,-8,6,2,-12,-10,63,1,-12,-9,2,2,-12,-8,6,2,-11,-10,63,1,-11,-9,2,2,-11,-8,6,2,-11,7,54,1,-11,8,1,2,-11,9,5,2,-10,-5,54,1,-10,-4,1,2,-10,-3,5,2,-10,7,63,1,-10,8,2,2,-10,9,6,2,-9,-5,63,1,-9,-4,2,2,-9,-3,6,2,-9,7,63,1,-9,8,2,2,-9,9,6,2,-8,-5,63,1,-8,-4,2,2,-8,-3,6,2,-8,7,63,1,-8,8,2,2,-8,9,6,2,-7,-5,63,1,-7,-4,2,2,-7,-3,6,2,-7,7,63,1,-7,8,2,2,-7,9,6,2,-6,-5,63,1,-6,-4,2,2,-6,-3,6,2,-6,7,63,1,-6,8,2,2,-6,9,6,2,-5,-5,63,1,-5,-4,2,2,-5,-3,6,2,-5,7,63,1,-5,8,2,2,-5,9,6,2,-4,-5,63,1,-4,-4,2,2,-4,-3,6,2,-4,7,63,1,-4,8,2,2,-4,9,6,2,-3,-5,27,1,-3,-4,3,2,-3,-3,7,2,-3,7,27,1,-3,8,3,2,-3,9,7,2,-2,-7,63,1,-2,-6,2,2,-2,-5,6,2,-2,6,63,1,-2,7,2,2,-2,8,6,2,-1,-7,63,1,-1,-6,2,2,-1,-5,6,2,-1,6,63,1,-1,7,2,2,-1,8,6,2,0,-7,63,1,0,-6,2,2,0,-5,6,2,0,6,27,1,0,7,3,2,0,8,7,2,1,-7,63,1,1,-6,2,2,1,-5,6,2,2,-7,63,1,2,-6,2,2,2,-5,6,2,3,-7,63,1,3,-6,2,2,3,-5,6,2,3,6,54,1,3,7,1,2,3,8,5,2,4,-7,63,1,4,-6,2,2,4,-5,6,2,4,6,63,1,4,7,2,2,4,8,6,2,5,-7,63,1,5,-6,2,2,5,-5,6,2,5,6,63,1,5,7,2,2,5,8,6,2],"Top":[-19,-11,511,1,-19,-10,511,1,-19,-9,511,1,-19,-8,511,1,-19,-7,511,1,-19,-6,511,1,-19,-5,511,1,-19,-4,511,1,-19,-3,511,1,-19,-2,511,1,-19,-1,511,1,-19,0,511,1,-19,1,511,1,-19,2,511,1,-19,3,511,1,-19,4,511,1,-18,-11,511,1,-18,-10,255,1,-18,-9,219,1,-18,-8,219,1,-18,-7,219,1,-18,-6,219,1,-18,-5,219,1,-18,-4,219,1,-18,-3,219,1,-18,-2,219,1,-18,-1,219,1,-18,0,219,1,-18,1,219,1,-18,2,219,1,-18,3,507,1,-18,4,511,1,-17,-11,511,1,-17,3,504,1,-17,4,511,1,-16,-11,511,1,-16,3,504,1,-16,4,511,1,-15,-11,511,1,-15,3,504,1,-15,4,511,1,-15,5,511,1,-15,6,511,1,-15,7,511,1,-15,8,511,1,-15,9,511,1,-15,10,511,1,-15,11,511,1,-15,12,511,1,-14,-11,511,1,-14,3,216,1,-14,4,219,1,-14,5,219,1,-14,6,219,1,-14,7,219,1,-14,8,219,1,-14,9,219,1,-14,10,219,1,-14,11,507,1,-14,12,511,1,-13,-11,511,1,-13,11,504,1,-13,12,511,1,-12,-11,511,1,-12,11,504,1,-12,12,511,1,-11,-11,511,1,-11,3,432,1,-11,4,438,1,-11,5,438,1,-11,6,438,1,-11,11,504,1,-11,12,511,1,-10,-11,511,1,-10,-10,447,1,-10,-9,438,1,-10,-8,438,1,-10,-7,438,1,-10,-6,438,1,-10,-1,432,1,-10,0,438,1,-10,1,438,1,-10,2,438,1,-10,3,510,1,-10,4,511,1,-10,5,511,1,-10,6,511,1,-10,11,504,1,-10,12,511,1,-9,-11,511,1,-9,-10,511,1,-9,-9,511,1,-9,-8,511,1,-9,-7,511,1,-9,-6,511,1,-9,-1,504,1,-9,0,511,1,-9,1,511,1,-9,2,511,1,-9,3,511,1,-9,4,511,1,-9,6,511,1,-9,11,504,1,-9,12,511,1,-8,-6,511,1,-8,-1,504,1,-8,0,511,1,-8,6,511,1,-8,11,504,1,-8,12,511,1,-7,-6,511,1,-7,-1,504,1,-7,0,511,1,-7,6,511,1,-7,11,504,1,-7,12,511,1,-6,-6,511,1,-6,-1,504,1,-6,0,511,1,-6,6,511,1,-6,11,504,1,-6,12,511,1,-5,-6,511,1,-5,-1,504,1,-5,0,511,1,-5,6,511,1,-5,11,504,1,-5,12,511,1,-4,-8,511,1,-4,-7,511,1,-4,-6,511,1,-4,-1,504,1,-4,0,511,1,-4,1,511,1,-4,2,511,1,-4,3,511,1,-4,5,511,1,-4,6,511,1,-4,11,504,1,-4,12,511,1,-4,13,511,1,-4,14,511,1,-4,15,511,1,-4,16,511,1,-3,-8,511,1,-3,-7,255,1,-3,-6,219,1,-3,-1,216,1,-3,0,219,1,-3,1,219,1,-3,2,507,1,-3,3,511,1,-3,5,511,1,-3,6,255,1,-3,11,216,1,-3,12,219,1,-3,13,219,1,-3,14,219,1,-3,15,507,1,-3,16,511,1,-2,-8,511,1,-2,2,504,1,-2,3,511,1,-2,5,511,1,-2,15,504,1,-2,16,511,1,-1,-8,511,1,-1,2,504,1,-1,3,511,1,-1,4,511,1,-1,5,511,1,-1,15,504,1,-1,16,511,1,0,-8,511,1,0,2,216,1,0,3,219,1,0,4,219,1,0,5,219,1,0,15,504,1,0,16,511,1,1,-8,511,1,1,15,504,1,1,16,511,1,2,-8,511,1,2,15,504,1,2,16,511,1,3,-8,511,1,3,2,432,1,3,3,438,1,3,4,438,1,3,5,438,1,3,15,504,1,3,16,511,1,4,-8,511,1,4,2,504,1,4,3,511,1,4,4,511,1,4,5,511,1,4,15,504,1,4,16,511,1,5,-8,511,1,5,2,504,1,5,3,511,1,5,5,511,1,5,15,504,1,5,16,511,1,6,-8,511,1,6,-7,447,1,6,-6,438,1,6,-5,438,1,6,-4,438,1,6,-3,438,1,6,-2,438,1,6,-1,438,1,6,0,438,1,6,1,438,1,6,2,510,1,6,3,511,1,6,5,511,1,6,6,447,1,6,7,438,1,6,8,438,1,6,9,438,1,6,10,438,1,6,11,438,1,6,12,438,1,6,13,438,1,6,14,438,1,6,15,510,1,6,16,511,1,7,-8,511,1,7,-7,511,1,7,-6,511,1,7,-5,511,1,7,-4,511,1,7,-3,511,1,7,-2,511,1,7,-1,511,1,7,0,511,1,7,1,511,1,7,2,511,1,7,3,511,1,7,5,511,1,7,6,511,1,7,7,511,1,7,8,511,1,7,9,511,1,7,10,511,1,7,11,511,1,7,12,511,1,7,13,511,1,7,14,511,1,7,15,511,1,7,16,511,1],"CustomFloor1":[],"CustomFloor2":[],"CustomFloor3":[],"CustomMiddle1":[],"CustomMiddle2":[],"CustomTop":[]} \ No newline at end of file +{"NavigationVertices":[{"X":-26,"Y":-26},{"X":-26,"Y":-58},{"X":90,"Y":-58},{"X":90,"Y":36},{"X":42,"Y":36},{"X":42,"Y":150},{"X":22,"Y":150},{"X":22,"Y":36},{"X":-26,"Y":-12},{"X":-26,"Y":36},{"X":-166,"Y":-26},{"X":-166,"Y":-12},{"X":-166,"Y":52},{"X":-182,"Y":52},{"X":-26,"Y":166},{"X":-26,"Y":150},{"X":90,"Y":150},{"X":90,"Y":244},{"X":-26,"Y":244},{"X":-26,"Y":180},{"X":-182,"Y":166},{"X":-202,"Y":180},{"X":-202,"Y":52},{"X":-266,"Y":52},{"X":-266,"Y":-106},{"X":-166,"Y":-106}],"NavigationPolygon":[[0,1,2,3,4],[4,5,6,7],[0,4,7,8],[7,9,8],[10,0,8,11],[11,12,13],[14,15,6],[5,16,17,18,19],[6,5,19,14],[20,14,19,21],[20,21,22,13],[22,23,24,25,10],[22,10,11,13]],"Floor":[-2,-4,0,3,-1,-4,0,3,-1,-3,0,3,0,-2,0,3,1,-2,0,3,1,-1,0,3,2,-1,0,3,3,-1,0,3,3,0,0,3,4,0,0,3,5,0,0,3,5,1,0,3,-2,-3,0,3,-2,-2,0,3,-2,-1,0,3,-2,0,0,3,-1,-2,0,3,-1,-1,0,3,-1,0,0,3,0,-4,0,3,0,-3,0,3,0,-1,0,3,0,0,0,3,1,-4,0,3,1,-3,0,3,1,0,0,3,2,-4,0,3,2,-3,0,3,2,-2,0,3,2,0,0,3,3,-4,0,3,3,-3,0,3,3,-2,0,3,4,-4,0,3,4,-3,0,3,4,-2,0,3,4,-1,0,3,5,-4,0,3,5,-3,0,3,5,-2,0,3,5,-1,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,4,1,0,3,1,2,0,3,2,2,0,3,-2,9,0,3,-2,10,0,3,-2,11,0,3,-2,12,0,3,-2,13,0,3,-2,14,0,3,-1,9,0,3,-1,10,0,3,-1,11,0,3,-1,12,0,3,-1,13,0,3,-1,14,0,3,0,9,0,3,0,10,0,3,0,11,0,3,0,12,0,3,0,13,0,3,0,14,0,3,1,9,0,3,1,10,0,3,1,11,0,3,1,12,0,3,1,13,0,3,1,14,0,3,2,9,0,3,2,10,0,3,2,11,0,3,2,12,0,3,2,13,0,3,2,14,0,3,3,9,0,3,3,10,0,3,3,11,0,3,3,12,0,3,3,13,0,3,3,14,0,3,4,9,0,3,4,10,0,3,4,11,0,3,4,12,0,3,4,13,0,3,4,14,0,3,5,9,0,3,5,10,0,3,5,11,0,3,5,12,0,3,5,13,0,3,5,14,0,3,1,3,0,3,1,4,0,3,1,5,0,3,1,6,0,3,1,7,0,3,1,8,0,3,2,3,0,3,2,4,0,3,2,5,0,3,2,6,0,3,2,7,0,3,2,8,0,3,-17,-7,0,3,-17,-6,0,3,-16,-6,0,3,-16,-5,0,3,-15,-5,0,3,-15,-4,0,3,-14,-3,0,3,-14,-2,0,3,-13,-2,0,3,-13,-1,0,3,-12,-1,0,3,-12,0,0,3,-11,0,0,3,-11,1,0,3,-17,-5,0,3,-17,-4,0,3,-17,-3,0,3,-17,-2,0,3,-17,-1,0,3,-17,0,0,3,-17,1,0,3,-17,2,0,3,-16,-7,0,3,-16,-4,0,3,-16,-3,0,3,-16,-2,0,3,-16,-1,0,3,-16,0,0,3,-16,1,0,3,-16,2,0,3,-15,-7,0,3,-15,-6,0,3,-15,-3,0,3,-15,-2,0,3,-15,-1,0,3,-15,0,0,3,-15,1,0,3,-15,2,0,3,-14,-7,0,3,-14,-6,0,3,-14,-5,0,3,-14,-4,0,3,-14,-1,0,3,-14,0,0,3,-14,1,0,3,-14,2,0,3,-13,-7,0,3,-13,-6,0,3,-13,-5,0,3,-13,-4,0,3,-13,-3,0,3,-13,0,0,3,-13,1,0,3,-13,2,0,3,-12,-7,0,3,-12,-6,0,3,-12,-5,0,3,-12,-4,0,3,-12,-3,0,3,-12,-2,0,3,-12,1,0,3,-12,2,0,3,-11,-7,0,3,-11,-6,0,3,-11,-5,0,3,-11,-4,0,3,-11,-3,0,3,-11,-2,0,3,-11,-1,0,3,-11,2,0,3,-10,-2,0,3,-9,-2,0,3,-8,-2,0,3,-7,-2,0,3,-6,-2,0,3,-5,-2,0,3,-4,-2,0,3,-3,-2,0,3,-13,3,0,3,-13,4,0,3,-13,5,0,3,-13,6,0,3,-13,7,0,3,-13,8,0,3,-13,9,0,3,-13,10,0,3,-12,3,0,3,-12,4,0,3,-12,5,0,3,-12,6,0,3,-12,7,0,3,-12,8,0,3,-12,9,0,3,-12,10,0,3,-11,10,0,3,-10,10,0,3,-9,10,0,3,-8,10,0,3,-7,10,0,3,-6,10,0,3,-5,10,0,3,-4,10,0,3,-3,10,0,3,-11,5,0,3],"Middle":[],"Top":[],"CustomFloor1":[],"CustomFloor2":[],"CustomFloor3":[],"CustomMiddle1":[],"CustomMiddle2":[],"CustomTop":[]} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/InfiniteGrid.cs b/DungeonShooting_Godot/src/framework/InfiniteGrid.cs index 32c73ba..85713a4 100644 --- a/DungeonShooting_Godot/src/framework/InfiniteGrid.cs +++ b/DungeonShooting_Godot/src/framework/InfiniteGrid.cs @@ -94,8 +94,11 @@ { if (_map.TryGetValue(x, out var value)) { - _isDirty = true; - return value.Remove(y); + if (value.Remove(y)) + { + _isDirty = true; + return true; + } } return false; @@ -145,11 +148,14 @@ { if (_map.TryGetValue(x + i, out var value)) { - value.Remove(y + j); + if (value.Remove(y + j)) + { + _isDirty = true; + } + if (value.Count == 0) { _map.Remove(x + i); - _isDirty = true; } } } diff --git a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs index cba1da9..3e9aa7c 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs @@ -300,7 +300,7 @@ var space = _rule.GetNextRoomInterval(prevRoom, roomType, direction); if (direction == RoomDirection.Up || direction == RoomDirection.Down) { - space += 1; + space += 2; } //中心偏移 var offset = _rule.GetNextRoomOffset(prevRoom, roomType, direction); @@ -583,40 +583,44 @@ nextRoomDoor.ConnectRoom = roomInfo; nextRoomDoor.ConnectDoor = roomDoor; - //先寻找直通门 - if (Random.RandomBoolean()) - { - //直行通道, 优先横轴 - if (TryConnectHorizontalDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor) - || TryConnectVerticalDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor)) - { - return true; - } - } - else - { - //直行通道, 优先纵轴 - if (TryConnectVerticalDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor) - || TryConnectHorizontalDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor)) - { - return true; - } - } + // //先寻找直通门 + // if (Random.RandomBoolean()) + // {s + // //直行通道, 优先纵轴 + // if (TryConnectVerticalDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor) + // || TryConnectHorizontalDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor)) + // { + // return true; + // } + // } + // else + // { + // //直行通道, 优先横轴 + // if (TryConnectHorizontalDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor) + // || TryConnectVerticalDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor)) + // { + // return true; + // } + // } - //包含拐角的通道 + //包含1个拐角的通道 return TryConnectCrossDoor(roomInfo, roomDoor, nextRoomInfo, nextRoomDoor); + //包含2个拐角的通道 (后面再开发) } /// - /// 尝试寻找横轴方向上两个房间的连通的门, 只查找直线通道, 返回是否找到 + /// 尝试寻找纵轴方向上两个房间的连通的门, 只查找直线通道, 返回是否找到 /// - private bool TryConnectHorizontalDoor(RoomInfo roomInfo, RoomDoorInfo roomDoor, RoomInfo nextRoomInfo, RoomDoorInfo nextRoomDoor) + private bool TryConnectVerticalDoor(RoomInfo roomInfo, RoomDoorInfo roomDoor, RoomInfo nextRoomInfo, RoomDoorInfo nextRoomDoor) { var overlapX = Mathf.Min(roomInfo.GetHorizontalEnd(), nextRoomInfo.GetHorizontalEnd()) - Mathf.Max(roomInfo.GetHorizontalStart(), nextRoomInfo.GetHorizontalStart()); //这种情况下x轴有重叠 if (overlapX >= 6) { + //填充通通道地板格子 + var floorCell = new HashSet(); + //找到重叠区域 var rangeList = FindPassage(roomInfo, nextRoomInfo, roomInfo.GetVerticalStart() < nextRoomInfo.GetVerticalStart() ? DoorDirection.S : DoorDirection.N); @@ -633,6 +637,12 @@ nextRoomDoor.Direction = DoorDirection.N; roomDoor.OriginPosition = new Vector2I(x, roomInfo.GetVerticalDoorEnd()); nextRoomDoor.OriginPosition = new Vector2I(x, nextRoomInfo.GetVerticalDoorStart()); + + for (var i = roomInfo.GetVerticalDoorEnd() - 1; i < nextRoomInfo.GetVerticalDoorStart() + 1; i++) + { + floorCell.Add(new Vector2I(x + 1, i)); + floorCell.Add(new Vector2I(x + 2, i)); + } } else //room在下, nextRoom在上 { @@ -640,18 +650,28 @@ nextRoomDoor.Direction = DoorDirection.S; roomDoor.OriginPosition = new Vector2I(x, roomInfo.GetVerticalDoorStart()); nextRoomDoor.OriginPosition = new Vector2I(x, nextRoomInfo.GetVerticalDoorEnd()); + + for (var i = nextRoomInfo.GetVerticalDoorEnd() - 1; i < roomInfo.GetVerticalDoorStart() + 1; i++) + { + floorCell.Add(new Vector2I(x + 1, i)); + floorCell.Add(new Vector2I(x + 2, i)); + } } //判断门之间的通道是否有物体碰到 if (!AddCorridorToGridRange(roomDoor, nextRoomDoor)) { //此门不能连通 + floorCell.Clear(); continue; } //没有撞到物体 roomInfo.Doors.Add(roomDoor); nextRoomInfo.Doors.Add(nextRoomDoor); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } } @@ -660,15 +680,18 @@ } /// - /// 尝试寻找纵轴方向上两个房间的连通的门, 只查找直线通道, 返回是否找到 + /// 尝试寻找横轴方向上两个房间的连通的门, 只查找直线通道, 返回是否找到 /// - private bool TryConnectVerticalDoor(RoomInfo roomInfo, RoomDoorInfo roomDoor, RoomInfo nextRoomInfo, RoomDoorInfo nextRoomDoor) + private bool TryConnectHorizontalDoor(RoomInfo roomInfo, RoomDoorInfo roomDoor, RoomInfo nextRoomInfo, RoomDoorInfo nextRoomDoor) { var overlapY = Mathf.Min(roomInfo.GetVerticalEnd(), nextRoomInfo.GetVerticalEnd()) - Mathf.Max(roomInfo.GetVerticalStart(), nextRoomInfo.GetVerticalStart()); //这种情况下y轴有重叠 if (overlapY >= 6) { + //填充通通道地板格子 + var floorCell = new HashSet(); + //找到重叠区域 var rangeList = FindPassage(roomInfo, nextRoomInfo, roomInfo.GetHorizontalStart() < nextRoomInfo.GetHorizontalStart() ? DoorDirection.E : DoorDirection.W); @@ -685,6 +708,11 @@ nextRoomDoor.Direction = DoorDirection.W; roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorEnd(), y); nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart(), y); + + for (var i = roomInfo.GetHorizontalDoorEnd() - 1; i < nextRoomInfo.GetHorizontalDoorStart() + 1; i++) + { + floorCell.Add(new Vector2I(i, y + 2)); + } } else //room在右, nextRoom在左 { @@ -692,18 +720,27 @@ nextRoomDoor.Direction = DoorDirection.E; roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorStart(), y); nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorEnd(), y); + + for (var i = nextRoomInfo.GetHorizontalDoorEnd() - 1; i < roomInfo.GetHorizontalDoorStart() + 1; i++) + { + floorCell.Add(new Vector2I(i, y + 2)); + } } //判断门之间的通道是否有物体碰到 if (!AddCorridorToGridRange(roomDoor, nextRoomDoor)) { //此门不能连通 + floorCell.Clear(); continue; } //没有撞到物体 roomInfo.Doors.Add(roomDoor); nextRoomInfo.Doors.Add(nextRoomDoor); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } } @@ -963,15 +1000,33 @@ offset1 += 1; offset2 += 1; roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorStart() + offset1, roomInfo.GetVerticalDoorStart()); - nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorEnd(), - nextRoomInfo.GetVerticalDoorStart() + offset2); + nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorEnd(), nextRoomInfo.GetVerticalDoorStart() + offset2); cross = new Vector2I(roomDoor.OriginPosition.X, nextRoomDoor.OriginPosition.Y); + + var floorCell = new HashSet(); + + //纵轴地板 + for (var y = cross.Y + 3; y <= roomDoor.OriginPosition.Y; y++) + { + floorCell.Add(new Vector2I(roomDoor.OriginPosition.X + 1, y)); + floorCell.Add(new Vector2I(roomDoor.OriginPosition.X + 2, y)); + } + //横轴地板 + for (var x = nextRoomDoor.OriginPosition.X - 1; x <= cross.X; x++) + { + floorCell.Add(new Vector2I(x, nextRoomDoor.OriginPosition.Y + 2)); + } + //交叉点地板 + floorCell.Add(new Vector2I(cross.X + 1, cross.Y + 2)); + floorCell.Add(new Vector2I(cross.X + 2, cross.Y + 2)); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } private bool TryConnect_WS_Door(RoomInfo roomInfo, RoomInfo nextRoomInfo, RoomDoorInfo roomDoor, RoomDoorInfo nextRoomDoor, ref Vector2I cross) { - //ok var offset1 = 0; var offset2 = 0; roomDoor.Direction = DoorDirection.W; //← @@ -987,6 +1042,27 @@ roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorStart(), roomInfo.GetVerticalDoorStart() + offset1); nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart() + offset2, nextRoomInfo.GetVerticalDoorEnd()); cross = new Vector2I(nextRoomDoor.OriginPosition.X, roomDoor.OriginPosition.Y); + + var floorCell = new HashSet(); + + //横轴地板 + for (var x = cross.X + 3; x <= roomDoor.OriginPosition.X; x++) + { + floorCell.Add(new Vector2I(x, roomDoor.OriginPosition.Y + 2)); + } + //纵轴地板 + for (var y = nextRoomDoor.OriginPosition.Y - 1; y <= cross.Y + 1; y++) + { + floorCell.Add(new Vector2I(nextRoomDoor.OriginPosition.X + 1, y)); + floorCell.Add(new Vector2I(nextRoomDoor.OriginPosition.X + 2, y)); + } + + //交叉点地板 + floorCell.Add(new Vector2I(cross.X + 1, cross.Y + 2)); + floorCell.Add(new Vector2I(cross.X + 2, cross.Y + 2)); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } @@ -1005,9 +1081,30 @@ offset1 += 1; offset2 += 1; roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorStart() + offset1, roomInfo.GetVerticalDoorEnd()); - nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorEnd(), - nextRoomInfo.GetVerticalDoorStart() + offset2); + nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorEnd(), nextRoomInfo.GetVerticalDoorStart() + offset2); cross = new Vector2I(roomDoor.OriginPosition.X, nextRoomDoor.OriginPosition.Y); + + var floorCell = new HashSet(); + + //纵轴地板 + for (var y = roomDoor.OriginPosition.Y - 1; y <= cross.Y + 1; y++) + { + floorCell.Add(new Vector2I(roomDoor.OriginPosition.X + 1, y)); + floorCell.Add(new Vector2I(roomDoor.OriginPosition.X + 2, y)); + } + + //横轴地板 + for (var x = nextRoomDoor.OriginPosition.X - 1; x <= cross.X; x++) + { + floorCell.Add(new Vector2I(x, nextRoomDoor.OriginPosition.Y + 2)); + } + + //交叉点地板 + floorCell.Add(new Vector2I(cross.X + 1, cross.Y + 2)); + floorCell.Add(new Vector2I(cross.X + 2, cross.Y + 2)); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } @@ -1025,11 +1122,31 @@ offset1 += 1; offset2 += 1; - roomDoor.OriginPosition = - new Vector2I(roomInfo.GetHorizontalDoorStart(), roomInfo.GetVerticalDoorStart() + offset1); // - nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart() + offset2, - nextRoomInfo.GetVerticalDoorStart()); + roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorStart(), roomInfo.GetVerticalDoorStart() + offset1); // + nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart() + offset2, nextRoomInfo.GetVerticalDoorStart()); cross = new Vector2I(nextRoomDoor.OriginPosition.X, roomDoor.OriginPosition.Y); + + var floorCell = new HashSet(); + + //横轴地板 + for (var x = cross.X + 3; x <= roomDoor.OriginPosition.X; x++) + { + floorCell.Add(new Vector2I(x, roomDoor.OriginPosition.Y + 2)); + } + + //纵轴地板 + for (var y = cross.Y + 3; y <= nextRoomDoor.OriginPosition.Y; y++) + { + floorCell.Add(new Vector2I(nextRoomDoor.OriginPosition.X + 1, y)); + floorCell.Add(new Vector2I(nextRoomDoor.OriginPosition.X + 2, y)); + } + + //交叉点地板 + floorCell.Add(new Vector2I(cross.X + 1, cross.Y + 2)); + floorCell.Add(new Vector2I(cross.X + 2, cross.Y + 2)); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } @@ -1048,9 +1165,30 @@ offset1 += 1; offset2 += 1; roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorEnd(), roomInfo.GetVerticalDoorStart() + offset1); - nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart() + offset2, - nextRoomInfo.GetVerticalDoorEnd()); + nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart() + offset2, nextRoomInfo.GetVerticalDoorEnd()); cross = new Vector2I(nextRoomDoor.OriginPosition.X, roomDoor.OriginPosition.Y); + + var floorCell = new HashSet(); + + //横轴地板 + for (var x = roomDoor.OriginPosition.X - 1; x <= cross.X; x++) + { + floorCell.Add(new Vector2I(x, roomDoor.OriginPosition.Y + 2)); + } + + //纵轴地板 + for (var y = nextRoomDoor.OriginPosition.Y - 1; y <= cross.Y + 1; y++) + { + floorCell.Add(new Vector2I(nextRoomDoor.OriginPosition.X + 1, y)); + floorCell.Add(new Vector2I(nextRoomDoor.OriginPosition.X + 2, y)); + } + + //交叉点地板 + floorCell.Add(new Vector2I(cross.X + 1, cross.Y + 2)); + floorCell.Add(new Vector2I(cross.X + 2, cross.Y + 2)); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } @@ -1069,9 +1207,30 @@ offset1 += 1; offset2 += 1; roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorStart() + offset1, roomInfo.GetVerticalDoorStart()); - nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart(), - nextRoomInfo.GetVerticalDoorStart() + offset2); + nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart(), nextRoomInfo.GetVerticalDoorStart() + offset2); cross = new Vector2I(roomDoor.OriginPosition.X, nextRoomDoor.OriginPosition.Y); + + var floorCell = new HashSet(); + + //纵轴地板 + for (var y = cross.Y + 3; y <= roomDoor.OriginPosition.Y; y++) + { + floorCell.Add(new Vector2I(roomDoor.OriginPosition.X + 1, y)); + floorCell.Add(new Vector2I(roomDoor.OriginPosition.X + 2, y)); + } + + //横轴地板 + for (var x = cross.X + 3; x <= nextRoomDoor.OriginPosition.X; x++) + { + floorCell.Add(new Vector2I(x, nextRoomDoor.OriginPosition.Y + 2)); + } + + //交叉点地板 + floorCell.Add(new Vector2I(cross.X + 1, cross.Y + 2)); + floorCell.Add(new Vector2I(cross.X + 2, cross.Y + 2)); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } @@ -1089,10 +1248,31 @@ offset1 += 1; offset2 += 2; - roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorEnd(), - roomInfo.GetVerticalDoorStart() + offset1); + roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorEnd(), roomInfo.GetVerticalDoorStart() + offset1); nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalStart() + offset2, nextRoomInfo.GetVerticalDoorStart()); cross = new Vector2I(nextRoomDoor.OriginPosition.X, roomDoor.OriginPosition.Y); + + var floorCell = new HashSet(); + + //横轴地板 + for (var x = roomDoor.OriginPosition.X - 1; x <= cross.X; x++) + { + floorCell.Add(new Vector2I(x, roomDoor.OriginPosition.Y + 2)); + } + + //纵轴地板 + for (var y = cross.Y + 3; y <= nextRoomDoor.OriginPosition.Y; y++) + { + floorCell.Add(new Vector2I(nextRoomDoor.OriginPosition.X + 1, y)); + floorCell.Add(new Vector2I(nextRoomDoor.OriginPosition.X + 2, y)); + } + + //交叉点地板 + floorCell.Add(new Vector2I(cross.X + 1, cross.Y + 2)); + floorCell.Add(new Vector2I(cross.X + 2, cross.Y + 2)); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } @@ -1110,10 +1290,31 @@ offset1 += 1; offset2 += 1; - roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorStart() + offset1, - roomInfo.GetVerticalDoorEnd()); + roomDoor.OriginPosition = new Vector2I(roomInfo.GetHorizontalDoorStart() + offset1, roomInfo.GetVerticalDoorEnd()); nextRoomDoor.OriginPosition = new Vector2I(nextRoomInfo.GetHorizontalDoorStart(), nextRoomInfo.GetVerticalDoorStart() + offset2); cross = new Vector2I(roomDoor.OriginPosition.X, nextRoomDoor.OriginPosition.Y); + + var floorCell = new HashSet(); + + //纵轴地板 + for (var y = roomDoor.OriginPosition.Y - 1; y <= cross.Y + 1; y++) + { + floorCell.Add(new Vector2I(roomDoor.OriginPosition.X + 1, y)); + floorCell.Add(new Vector2I(roomDoor.OriginPosition.X + 2, y)); + } + + //横轴地板 + for (var x = cross.X + 3; x <= nextRoomDoor.OriginPosition.X; x++) + { + floorCell.Add(new Vector2I(x, nextRoomDoor.OriginPosition.Y + 2)); + } + + //交叉点地板 + floorCell.Add(new Vector2I(cross.X + 1, cross.Y + 2)); + floorCell.Add(new Vector2I(cross.X + 2, cross.Y + 2)); + + roomDoor.FloorCell = floorCell; + nextRoomDoor.FloorCell = floorCell; return true; } diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs index 7efac66..108302c 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs @@ -169,126 +169,14 @@ { continue; } - - //普通的直线连接 - var doorDir1 = doorInfo.Direction; - var doorDir2 = doorInfo.ConnectDoor.Direction; - if (!doorInfo.HasCross) - { - var rect = doorInfo.GetAisleRect(); - switch (doorDir1) - { - case DoorDirection.E: - FullHorizontalAisle(config, rect); - FullHorizontalAisleLeft(config, rect, doorInfo); - FullHorizontalAisleRight(config, rect, doorInfo.ConnectDoor); - break; - case DoorDirection.W: - FullHorizontalAisle(config, rect); - FullHorizontalAisleLeft(config, rect, doorInfo.ConnectDoor); - FullHorizontalAisleRight(config, rect, doorInfo); - break; - - case DoorDirection.S: - FullVerticalAisle(config, rect); - FullVerticalAisleUp(config, rect, doorInfo); - FullVerticalAisleDown(config, rect, doorInfo.ConnectDoor); - break; - case DoorDirection.N: - FullVerticalAisle(config, rect); - FullVerticalAisleUp(config, rect, doorInfo.ConnectDoor); - FullVerticalAisleDown(config, rect, doorInfo); - break; - } - } - else //带交叉点 - { - //方向, 0横向, 1纵向 - var dir1 = (doorDir1 == DoorDirection.S || doorDir1 == DoorDirection.N) ? 1 : 0; - var dir2 = (doorDir2 == DoorDirection.S || doorDir2 == DoorDirection.N) ? 1 : 0; - var aisleRect = doorInfo.GetCrossAisleRect(); - var rect = aisleRect.Rect1; - var rect2 = aisleRect.Rect2; - - //填充交叉点 - FillRect(MapLayer.AutoAisleFloorLayer, config.Floor, aisleRect.Cross.Position, aisleRect.Cross.Size); - - //墙壁, 0横向, 1纵向 - if (dir1 == 0) + //铺过道 + if (doorInfo.FloorCell != null) + { + yield return 0; + foreach (var p in doorInfo.FloorCell) { - FullHorizontalAisle(config, rect); - FullHorizontalAisleLeft(config, rect, doorDir1 == DoorDirection.E ? doorInfo : null); - FullHorizontalAisleRight(config, rect, doorDir1 == DoorDirection.W ? doorInfo : null); - } - else - { - FullVerticalAisle(config, rect); - FullVerticalAisleUp(config, rect, doorDir1 == DoorDirection.S ? doorInfo : null); - FullVerticalAisleDown(config, rect, doorDir1 == DoorDirection.N ? doorInfo : null); - } - - //墙壁, 0横向, 1纵向 - if (dir2 == 0) - { - FullHorizontalAisle(config, rect2); - FullHorizontalAisleLeft(config, rect2, doorDir2 == DoorDirection.E ? doorInfo.ConnectDoor : null); - FullHorizontalAisleRight(config, rect2, doorDir2 == DoorDirection.W ? doorInfo.ConnectDoor : null); - } - else - { - FullVerticalAisle(config, rect2); - FullVerticalAisleUp(config, rect2, doorDir2 == DoorDirection.S ? doorInfo.ConnectDoor : null); - FullVerticalAisleDown(config, rect2, doorDir2 == DoorDirection.N ? doorInfo.ConnectDoor : null); - } - - if ((doorDir1 == DoorDirection.N && doorDir2 == DoorDirection.E) || //↑→ - (doorDir2 == DoorDirection.N && doorDir1 == DoorDirection.E)) - { - 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_CenterTop, 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(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(MapLayer.AutoMiddleLayer, config.Wall_Out_RB, doorInfo.Cross + new Vector2I(0, -1), Vector2.One); - FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_RightTop, 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(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(MapLayer.AutoMiddleLayer, config.Wall_Out_LB, doorInfo.Cross + new Vector2(GameConfig.CorridorWidth - 1, -1), Vector2.One); - FillRect(MapLayer.AutoMiddleLayer, config.Wall_Vertical_LeftTop, 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(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(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_CenterTop, 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(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)); + _tileRoot.SetCell(MapLayer.AutoAisleFloorLayer, p, config.Floor.SourceId, config.Floor.AutoTileCoords); } } diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs index 3738cec..29a0c87 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs @@ -1,5 +1,6 @@ using System; +using System.Collections.Generic; using Godot; /// @@ -40,12 +41,22 @@ public Vector2I OriginPosition; /// - /// 与下一道门是否有交叉点 + /// 地板所占的地板格子, 单位: 格, 使用时不需要加上 OriginPosition + /// + public HashSet FloorCell; + + /// + /// 地板所占的矩形, 单位: 格 + /// + public Rect2I FloorRect; + + /// + /// 与下一道门是否有交叉点 (弃用) /// public bool HasCross; /// - /// 与下一道门的交叉点, 单位: 格 + /// 与下一道门的交叉点, 单位: 格 (弃用) /// public Vector2I Cross; diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index 7567d98..343f1d7 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -108,6 +108,15 @@ DungeonConfig = new DungeonConfig(); DungeonConfig.GroupName = "Test1"; DungeonConfig.BattleRoomCount = 15; + DungeonConfig.BossRoomCount = 0; + DungeonConfig.RewardRoomCount = 0; + DungeonConfig.ShopRoomCount = 0; + DungeonConfig.OutRoomCount = 0; + DungeonConfig.RoomHorizontalMinDispersion = -1; + DungeonConfig.RoomHorizontalMaxDispersion = 1; + DungeonConfig.RoomVerticalMinDispersion = -1; + DungeonConfig.RoomVerticalMaxDispersion = 1; + DungeonConfig.EnableLimitRange = false; } public override void _EnterTree() diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index f301669..ea0a6cd 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -61,7 +61,7 @@ ActivePropsPack.SetCapacity(1); // debug用 - // DebugSet(); + DebugSet(); //注册状态机 StateController.Register(new PlayerIdleState()); @@ -82,7 +82,7 @@ RoleState.MoveSpeed = 500; CollisionLayer = PhysicsLayer.None; CollisionMask = PhysicsLayer.None; - GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); + //GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); // this.CallDelay(0.5f, () => // { // PickUpWeapon(Create(Ids.Id_weapon0009)); diff --git a/DungeonShooting_Godot/src/game/room/DefaultDungeonRule.cs b/DungeonShooting_Godot/src/game/room/DefaultDungeonRule.cs index 115ada8..9475d69 100644 --- a/DungeonShooting_Godot/src/game/room/DefaultDungeonRule.cs +++ b/DungeonShooting_Godot/src/game/room/DefaultDungeonRule.cs @@ -27,7 +27,7 @@ public override bool CanOverGenerator() { - return Generator.BattleRoomInfos.Count >= Config.BattleRoomCount && Generator.EndRoomInfos.Count > 0; + return Generator.BattleRoomInfos.Count >= Config.BattleRoomCount && Generator.EndRoomInfos.Count >= Config.OutRoomCount; } public override RoomInfo GetConnectPrevRoom(RoomInfo prevRoom, DungeonRoomType nextRoomType)