diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/Preview.png b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/Preview.png index e011869..78f313b 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/Preview.png +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/Preview.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/RoomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/RoomInfo.json index 21874ff..041adf8 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/RoomInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/RoomInfo.json @@ -1 +1 @@ -{"Position":{"X":-4,"Y":-4},"Size":{"X":10,"Y":8},"DoorAreaInfos":[],"GroupName":"TestGroup2","RoomType":0,"RoomName":"Battle1","Weight":100,"Remark":""} \ No newline at end of file +{"Position":{"X":-4,"Y":-6},"Size":{"X":16,"Y":11},"DoorAreaInfos":[],"GroupName":"TestGroup2","RoomType":0,"RoomName":"Battle1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/TileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/TileInfo.json index 6dd2be8..07568fb 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/TileInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/battle/Battle1/TileInfo.json @@ -1 +1 @@ -{"NavigationList":[{"Type":0,"Points":[-40,-40,72,-40,72,48,-40,48]},{"Type":1,"Points":[-8,-16,40,-16,40,24,-8,24]}],"Floor":[-3,-3,0,0,8,-3,-2,0,0,8,-3,-1,0,0,8,-3,0,0,0,8,-3,1,0,0,8,-3,2,0,0,8,-2,-3,0,0,8,-2,-2,0,0,8,-2,-1,0,0,8,-2,0,0,0,8,-2,1,0,0,8,-2,2,0,0,8,-1,-3,0,0,8,-1,-2,0,0,8,-1,-1,0,0,8,-1,0,0,0,8,-1,1,0,0,8,-1,2,0,0,8,0,-3,0,0,8,0,-2,0,0,8,0,1,0,0,8,0,2,0,0,8,1,-3,0,0,8,1,-2,0,0,8,1,1,0,0,8,1,2,0,0,8,2,-3,0,0,8,2,-2,0,0,8,2,-1,0,0,8,2,0,0,0,8,2,1,0,0,8,2,2,0,0,8,3,-3,0,0,8,3,-2,0,0,8,3,-1,0,0,8,3,0,0,0,8,3,1,0,0,8,3,2,0,0,8,4,-3,0,0,8,4,-2,0,0,8,4,-1,0,0,8,4,0,0,0,8,4,1,0,0,8,4,2,0,0,8],"Middle":[-3,-4,0,2,7,-2,-4,0,2,7,-1,-4,0,2,7,0,-4,0,2,7,0,0,0,1,7,1,-4,0,2,7,1,0,0,3,7,2,-4,0,2,7,3,-4,0,2,7,4,-4,0,2,7],"Top":[-4,-4,0,3,4,-4,-3,0,3,3,-4,-2,0,3,3,-4,-1,0,3,3,-4,0,0,3,3,-4,1,0,3,3,-4,2,0,3,3,-4,3,0,11,2,-3,3,0,2,2,-2,3,0,2,2,-1,3,0,2,2,0,-1,0,1,2,0,3,0,2,2,1,-1,0,3,2,1,3,0,2,2,2,3,0,2,2,3,3,0,2,2,4,3,0,2,2,5,-4,0,1,4,5,-3,0,1,3,5,-2,0,1,3,5,-1,0,1,3,5,0,0,1,3,5,1,0,1,3,5,2,0,1,3,5,3,0,13,2]} \ No newline at end of file +{"NavigationVertices":[{"X":150,"Y":54},{"X":170,"Y":66},{"X":-42,"Y":66},{"X":106,"Y":54},{"X":170,"Y":-58},{"X":150,"Y":2},{"X":-42,"Y":-58},{"X":106,"Y":2},{"X":22,"Y":-30},{"X":22,"Y":22},{"X":-22,"Y":-30},{"X":-22,"Y":22}],"NavigationPolygon":[[0,1,2,3],[4,1,0,5],[6,4,5,7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,3,0,0,4,10,-4,0,0,4,10,-3,0,0,4,10,-2,0,0,4,10,-1,0,0,4,10,0,0,0,4,10,1,0,0,4,10,2,0,0,4,10,3,0,0,4],"Middle":[],"Top":[-4,-6,0,6,2,-4,-5,0,11,2,-4,-4,0,11,2,-4,-3,0,11,2,-4,-2,0,11,2,-4,-1,0,11,2,-4,0,0,11,2,-4,1,0,11,2,-4,2,0,11,2,-4,3,0,11,2,-4,4,0,6,1,-3,-6,0,9,3,-3,-5,0,2,4,-3,4,0,10,0,-2,-6,0,9,3,-2,-5,0,2,4,-2,4,0,10,0,-1,-6,0,9,3,-1,-5,0,2,4,-1,-2,0,8,0,-1,-1,0,8,3,-1,0,0,1,4,-1,4,0,10,0,0,-6,0,9,3,0,-5,0,2,4,0,-2,0,11,0,0,-1,0,11,3,0,0,0,3,4,0,4,0,10,0,1,-6,0,9,3,1,-5,0,2,4,1,4,0,10,0,2,-6,0,9,3,2,-5,0,2,4,2,4,0,10,0,3,-6,0,9,3,3,-5,0,2,4,3,4,0,10,0,4,-6,0,9,3,4,-5,0,2,4,4,4,0,10,0,5,-6,0,9,3,5,-5,0,2,4,5,4,0,10,0,6,-6,0,9,3,6,-5,0,2,4,6,4,0,10,0,7,-6,0,9,3,7,-5,0,2,4,7,0,0,8,0,7,1,0,8,3,7,2,0,1,4,7,4,0,10,0,8,-6,0,9,3,8,-5,0,2,4,8,0,0,11,0,8,1,0,11,3,8,2,0,3,4,8,4,0,10,0,9,-6,0,9,3,9,-5,0,2,4,9,4,0,10,0,10,-6,0,9,3,10,-5,0,2,4,10,4,0,10,0,11,-6,0,5,2,11,-5,0,8,1,11,-4,0,8,1,11,-3,0,8,1,11,-2,0,8,1,11,-1,0,8,1,11,0,0,8,1,11,1,0,8,1,11,2,0,8,1,11,3,0,8,1,11,4,0,5,1]} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/Preview.png b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/Preview.png index 981dc0f..f9e240c 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/Preview.png +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/Preview.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/RoomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/RoomInfo.json index d5051f7..995da13 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/RoomInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/RoomInfo.json @@ -1 +1 @@ -{"Position":{"X":-4,"Y":-2},"Size":{"X":8,"Y":7},"DoorAreaInfos":[],"GroupName":"TestGroup2","RoomType":2,"RoomName":"End1","Weight":100,"Remark":""} \ No newline at end of file +{"Position":{"X":-1,"Y":-4},"Size":{"X":9,"Y":10},"DoorAreaInfos":[],"GroupName":"TestGroup2","RoomType":2,"RoomName":"End1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/TileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/TileInfo.json index 400aefd..efd8c99 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/TileInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup2/outlet/End1/TileInfo.json @@ -1 +1 @@ -{"NavigationList":[{"Type":0,"Points":[-40,-8,40,-8,40,64,-40,64]}],"Floor":[-3,-1,0,0,8,-3,0,0,0,8,-3,1,0,0,8,-3,2,0,0,8,-3,3,0,0,8,-2,-1,0,0,8,-2,0,0,0,8,-2,1,0,0,8,-2,2,0,0,8,-2,3,0,0,8,-1,-1,0,0,8,-1,0,0,0,8,-1,1,0,0,8,-1,2,0,0,8,-1,3,0,0,8,0,-1,0,0,8,0,0,0,0,8,0,1,0,0,8,0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,4,4,0,0,0,4,3,0,0,0,4,5,1,0,0,4],"Middle":[],"Top":[-1,-4,0,6,2,-1,-3,0,11,2,-1,-2,0,11,2,-1,-1,0,11,2,-1,0,0,11,2,-1,1,0,11,2,-1,2,0,11,2,-1,3,0,11,2,-1,4,0,11,2,-1,5,0,6,1,0,-4,0,9,3,0,-3,0,2,4,0,5,0,10,0,1,-4,0,9,3,1,-3,0,2,4,1,5,0,10,0,2,-4,0,9,3,2,-3,0,2,4,2,0,0,0,0,2,1,0,1,2,2,2,0,1,4,2,5,0,10,0,3,-4,0,9,3,3,-3,0,2,4,3,1,0,2,3,3,2,0,2,4,3,5,0,10,0,4,-4,0,9,3,4,-3,0,2,4,4,1,0,3,3,4,2,0,3,4,4,5,0,10,0,5,-4,0,9,3,5,-3,0,2,4,5,5,0,10,0,6,-4,0,9,3,6,-3,0,2,4,6,5,0,10,0,7,-4,0,5,2,7,-3,0,8,1,7,-2,0,8,1,7,-1,0,8,1,7,0,0,8,1,7,1,0,8,1,7,2,0,8,1,7,3,0,8,1,7,4,0,8,1,7,5,0,5,1]} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index ca0c3be..9132f18 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -53,8 +53,6 @@ private UiBase _prevUi; private DungeonTileMap _dungeonTileMap; private DungeonGenerator _dungeonGenerator; - //房间内所有静态导航网格数据 - private List _roomStaticNavigationList; //用于检查房间敌人的计时器 private float _checkEnemyTimer = 0; @@ -221,12 +219,6 @@ //挂载过道导航区域 _dungeonTileMap.MountNavigationPolygon(World.TileRoot); yield return 0; - //过道导航区域数据 - _roomStaticNavigationList = new List(); - _roomStaticNavigationList.AddRange(_dungeonTileMap.GetPolygonData()); - yield return 0; - //门导航区域数据 - _roomStaticNavigationList.AddRange(_dungeonTileMap.GetConnectDoorPolygonData()); //初始化所有房间 yield return _dungeonGenerator.EachRoomCoroutine(InitRoom); @@ -278,8 +270,6 @@ _dungeonTileMap = null; AutoTileConfig = null; _dungeonGenerator = null; - _roomStaticNavigationList.Clear(); - _roomStaticNavigationList = null; UiManager.Hide_RoomUI(); yield return 0; @@ -377,32 +367,21 @@ //挂载房间导航区域 private void MountNavFromRoomInfo(RoomInfo roomInfo) { - throw new NotImplementedException(); - // var polygonArray = roomInfo.RoomSplit.TileInfo.NavigationList; - // var polygon = new NavigationPolygon(); - // var offset = roomInfo.GetOffsetPosition(); - // for (var i = 0; i < polygonArray.Count; i++) - // { - // var navigationPolygonData = polygonArray[i]; - // var tempPosArray = navigationPolygonData.GetPoints(); - // var polygonPointArray = new Vector2[tempPosArray.Length]; - // //这里的位置需要加上房间位置 - // for (var j = 0; j < tempPosArray.Length; j++) - // { - // polygonPointArray[j] = tempPosArray[j] + roomInfo.GetWorldPosition() - offset; - // } - // polygon.AddOutline(polygonPointArray); - // - // //存入汇总列表 - // var polygonData = new NavigationPolygonData(navigationPolygonData.Type); - // polygonData.SetPoints(polygonPointArray); - // _roomStaticNavigationList.Add(polygonData); - // } - // polygon.MakePolygonsFromOutlines(); - // var navigationPolygon = new NavigationRegion2D(); - // navigationPolygon.Name = "NavigationRegion" + (GetChildCount() + 1); - // navigationPolygon.NavigationPolygon = polygon; - // World.TileRoot.AddChild(navigationPolygon); + var offset = roomInfo.GetOffsetPosition(); + var worldPosition = roomInfo.GetWorldPosition() - offset; + var polygon = roomInfo.RoomSplit.TileInfo.NavigationPolygon; + var vertices = roomInfo.RoomSplit.TileInfo.NavigationVertices; + var polygonData = new NavigationPolygon(); + //这里的位置需要加上房间位置 + polygonData.Vertices = vertices.Select(v => v.AsVector2() + worldPosition).ToArray(); + for (var i = 0; i < polygon.Count; i++) + { + polygonData.AddPolygon(polygon[i]); + } + var navigationPolygon = new NavigationRegion2D(); + navigationPolygon.Name = "NavigationRegion" + (GetChildCount() + 1); + navigationPolygon.NavigationPolygon = polygonData; + World.TileRoot.AddChild(navigationPolygon); } //创建门 @@ -787,11 +766,6 @@ { if (ActivityObject.IsDebug) { - if (_dungeonTileMap != null && _roomStaticNavigationList != null) - { - //绘制ai寻路区域 - Utils.DrawNavigationPolygon(this, _roomStaticNavigationList.ToArray()); - } // StartRoomInfo?.EachRoom(info => // { // DrawRect(new Rect2(info.Waypoints * GameConfig.TileCellSize, new Vector2(16, 16)), Colors.Red); diff --git a/DungeonShooting_Godot/src/game/room/World.cs b/DungeonShooting_Godot/src/game/room/World.cs index ea87702..60d34d7 100644 --- a/DungeonShooting_Godot/src/game/room/World.cs +++ b/DungeonShooting_Godot/src/game/room/World.cs @@ -72,9 +72,10 @@ Color = Colors.Black; //临时处理, 加载TileSet - var tileSet = ResourceManager.Load(ResourcePath.resource_tileSet_map1_TileSet1_tres); - var tileSetAtlasSource = (TileSetAtlasSource)tileSet.GetSource(0); - tileSetAtlasSource.Texture = ImageTexture.CreateFromImage(Image.LoadFromFile("resource/tileSprite/map1/16x16 dungeon ii wall reconfig v04 spritesheet.png")); + var tileSet = ResourceManager.Load(ResourcePath.resource_tileSet_map2_TileSet2_tres); + //var tileSet = ResourceManager.Load(ResourcePath.resource_tileSet_map1_TileSet1_tres); + //var tileSetAtlasSource = (TileSetAtlasSource)tileSet.GetSource(0); + //tileSetAtlasSource.Texture = ImageTexture.CreateFromImage(Image.LoadFromFile("resource/tileSprite/map1/16x16 dungeon ii wall reconfig v04 spritesheet.png")); TileRoot.TileSet = tileSet; TileRoot.YSortEnabled = false; }